ply.SetModel not working

Ok so im running this on my init.lua

[lua]
function GM:PlayerLoadout( ply )

if ply:Team() == 1 then

	ply:Give( "weapon_physcannon" )
	ply:SetModel( "models/player/kleiner.mdl" )

elseif ply:Team() == 2 then
	ply:SetModel( "models/player/gman_high.mdl" )
	ply:Give( "weapon_physcannon" ) 	
end 

end
[/lua]

Maybe I need to run it on shared.lua( Edit: Tried shared, it failed) but when I die my charachter model hasnt changed and isnt either of these. Any help?

Have you precached the models?


util.PrecacheModel("models/player/kleiner.mdl")

Ah, no, I wasnt aware I needed to (first gamemode). I presume this goes in either the shared.lua or init.lua header?

Don’t set the player model in PlayerLoadout. Set it in PlayerSpawn.

Or better yet call it when it is supposed to be called. :wink:

Brilliant, problem fixed. Thanks guys. also one last quick question, Is there a way to colour a player (like make kleiner tinted blue) in lua without editing models. Looked through the wiki but couldnt find anything.

[editline]09:10PM[/editline]

Isn’t that only if your deriving from sandbox though?
Edit: Maybe not, I dont know at least it works and I will bare this in mind.

Player:SetColor(255, 255, 200, 255)

Or stick those together the right way:
Player:SetColor( 200, 200, 255, 255 )

[editline]04:25PM[/editline]

entity.SetColor accepts four arguments: r, g, b, and a. It does not accept color structures.

As a note the answer to your question so you definitely know: No.

It is not Sandbox specific.

Great, thankyou all.