Ragdoll has no Physics Objects?

So here’s what I"m trying to do:

[lua]pl:CreateRagdoll()
local rag = pl:GetRagdollEntity()
rag:GetPhysicsObjectNum(10):ApplyForce(Vector(0,0,1000))
[/lua]

It creates the ragdoll and it’s a valid ragdoll entity, but when I try and ApplyForce I get this error:

autorun/server/exp_powerups.lua:673: attempt to index a nil value

I tried print( rag:GetPhysicsObjectCount() ), and it printed 0.

What’s going on here?

It’s probably because it’s the clientside ragdoll and physobject shit doesn’t work clientside I believe.

Both functions are being called serverside. Or do you mean it just does the clientside function on every client and doesn’t work from there?
Then that sucks.

The player ragdoll is clientside, so you will have to track it on the client and then do whatever you want with it. I’m using this for my TF2 gamemode:

[lua]hook.Add(“OnEntityCreated”, “PlayerRagdollCreated”, function(ent)
if ValidEntity(ent) and ent:GetClass()==“class C_HL2MPRagdoll” then
for _,v in pairs(player.GetAll()) do
if v:GetRagdollEntity()==ent then
gamemode.Call(“SetupPlayerRagdoll”, v, ent)
return
end
end
end
end)

function GM:SetupPlayerRagdoll(pl, rag)
– Do your stuff here
end[/lua]