Setting player model in sandbox?

So i’ve been messing around with player:SetModel() and it seams like noting is happening?



concommand.Add("test", function(ply)

    ply:SetModel("models/player/Group02/Female_02.mdl")

end)


Anyone know why this doesn’t work? Is sandbox overwriting something?

Make sure you set that console command in the SERVER realm… If you try to change the model on the CLIENT then it’ll set it for a frame or so, then change back; the reason SetModel is a SHARED function is so the CLIENT can call it on ClientsideModels, etc…

Also, I’d recommend always using lowercase for all file-names / paths so that, if used on linux, the files will be found.

So setting ply model is basily a shared thing!? Wow, didn’t notise that…

[editline]20th February 2015[/editline]

The thing is just, that the command is on server side?

Setting a player’s model is serverside

concommand.Add is shared.

[lua]
if SERVER then
concommand.Add(“test”, function(ply)
ply:SetModel(“models/player/Group02/Female_02.mdl”)
end)
end
[/lua]
This is what you want.

[editline]lkljh[/editline]
Whoops, you’re right Acecool. I made a big mistake.
Forgive me senpai. I fixed it.

No, actually this is what the op wants:

[lua]if ( SERVER ) then
concommand.Add( “dev_setmodel”, function( _p, _cmd, _args )
_p:SetModel( “models/player/Group02/Female_02.mdl” );
end );
end
[/lua]

Because concommand.Add is shared, if it gets added on the client then if the client types it into console nothing will happen. It’ll only change if the server types it but then _p would be NULL and would error…

The command needs to be created on the SERVER.

Explanation of console commands and realms: https://dl.dropboxusercontent.com/u/26074909/tutoring/_tutorial_quizzes/explanation_of_realms.lua.html