Set PlayerModel on weapon equip help.

So basically im trying to edit a weapon to where on equip it changes your model to the combine super soldier.

This is the code


util.PrecacheModel( "models/Combine_Super_Soldier" )
function ply:PlayerSetModel(ply)
   local mdl = GAMEMODE.playermodel or "Combine_Super_Soldier"
   util.PrecacheModel(mdl)
   ply:SetModel(mdl)

   ply:SetColor(GAMEMODE.playercolor or COLOR_WHITE)
end

this is the error I get

[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_juggernaut/shared.lua:11: attempt to index global ‘ply’ (a nil value)

I don’t know what I’m doing wrong.

I’m still kinda new to lua, I’ve fixed some printers and coded some pointshop addons but pretty basic stuff.

So mind me if this is a dumb question. But it’s not bad asking for help right?

Instead of ply, just use self.Owner.

[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_juggernaut/shared.lua:11: ‘)’ expected near ‘.’

uhm ok?

Could you give me a example, maybe show me where to put it? I put self.Owner on all of them and got that.



function SWEP:Deploy()
timer.Simple(0.1, function()
self.Owner:SetModel("models/player/combine_super_soldier.mdl")
self:Remove()
end)
end


Or, show us your code and show us what line 11 is, and we can tell you what you did wrong.

Not to mention the error literally tells you what you did wrong.

Thank you so much, this saved my ass. This was a winner right here.

As for nook, I apoligize, I didn’t see that when I copy pasted the error, it cut out the other two lines.

Solved