Setting a players bodygroup with a swep

Hey all,

Just trying to work out how to set a players bodygroup, when I equip a certain swep, here is the code so far.

[lua]
function Claw(pl)

local ply = player.GetByID( 1 )

    ply:SetBodyGroup( 5, 2 );

end

function SWEP:Deploy()
self.Owner:EmitSound( “weapons/knife/knife_deploy1.wav” );
Claw()
return true;
end
[/lua]

But just continues to say SetBodyGroup is a nil value which means its not picking up the playermodel as a entity.

Has anyone got any ideas?

yes, your using ply instead of pl? try fixing that :slight_smile:

Also your calling your function claw without the proper parameters, fix this.

Hey thanks for the quick reply :), Unfortunately it still thinks its a Nil value.

[editline]01:14AM[/editline]

Hmmm tried it yet it still doesnt work :S

[lua]
function Claw(ply)

local ply = player.GetByID( 1 )

    ply:SetBodyGroup( 5, 2 );

end

function SWEP:Deploy()
local ply = player.GetByID( 1 )
self.Owner:EmitSound( “weapons/knife/knife_deploy1.wav” );
Claw(ply)
return true;
end

[/lua]

Still I get the same error message saying SetBodyGroup is a nil value.

[editline]02:10AM[/editline]

Still havent fixed the problem, Any ideas?

Just woke up, Just so you know I am still looking for the answer if anyone knows?