Garry's Mod Wiki

Entity:GetRagdollOwner

  Entity Entity:GetRagdollOwner()

Description

Returns the entity which the ragdoll came from. The opposite of Player:GetRagdollEntity.

Returns

1 Entity
The entity who owns the ragdoll.

Example

Loop through all player ragdolls and print their owners.

local strRagdoll = SERVER and "hl2mp_ragdoll" or "class C_HL2MPRagdoll" for _, ent in ipairs( ents.FindByClass( strRagdoll ) ) do if ( IsValid( ent:GetRagdollOwner() ) ) then print( ent:GetRagdollOwner() ) end end
Output: While a player is dead and their ragdoll is spawned this returns:
Player [1][PlayerName]