Help with Setting Ply Model Function

Hey guys, me and a friend are currently working on a gamemode for our server, its RP based. We have setup a character creation menu, when you go to select a model you click an icon and the script should asign that model for you however it doesn’t we are having trouble with this part of the script:
[lua]local Icon1 = vgui.Create( “SpawnIcon”, DermaList )
Icon1:SetModel( “models/humans/group01/male_01.mdl” )
DermaList:AddItem( Icon1 )
Icon1.DoClick = function()
DermaPanel:SetVisible( false )
Self:SetModel( “models/Humans/group01/male_03” )
RunConsoleCommand( “team_3” )

It just won’t set the model that is shown there. Always reverts back to the gray one. We have tryed using the GM:SetModel and Ply:SetModel and as you can see we have also used self but we always get this error in console
[lua]PTRP\gamemode\cl_charcreate.lua:79: attempt to index global ‘Self’ (a nil value)[/lua]

If i haven’t explained this clearly enough just say so and ill have another crack but any help is appreciated

What error do you get with ply:SetModel?

Self isn’t defined, also SetModel is server side (i assume).


With the ply set model function i get this error.
[lua]PTRP\gamemode\cl_charcreate.lua:79: attempt to index global ‘Ply’ (a nil value)[/lua]

And yes the SetModel function is server side, so your saying i need a client side function to change the model to the one they selected in the character menu?

Put ply in the function arguments?

Change Ply or Self with LocalPlayer(), if that doesn’t work add this to your init.lua
[lua]concommand.Add( “ChangeModel”, function( ply, cmd, args )

if args[1] then
	ply:SetModel( args[1] );

end );[/lua]

and use this
[lua]local Icon1 = vgui.Create( “SpawnIcon”, DermaList )
Icon1:SetModel( “models/humans/group01/male_01.mdl” )
DermaList:AddItem( Icon1 )
Icon1.DoClick = function()

DermaPanel:SetVisible( false ) 
RunConsoleCommand( "ChangeModel", "models/humans/group01/male_01.mdl" )
RunConsoleCommand( "team_3" ) 


Not garunteed to work as it is untested.



According to the wiki, it is.

Thats on Entity.SetModel(). Im sure thats wrong though.

GM:PlayerSetModel( (Player) ply )

Thats what i found under gamemode hooks, it says it serverside, but is a hook the wrong thing to use here?

Thanks for replys


Well we got it working now, you spawn as the model you chose, however you have the glitchy mingebag animations (arms out straight, sliding around). We are testing in singleplayer atm and to my knowledge the source shared models 07 should be loaded correct? This is what stops glitchy animations?

use it’s player model, I think it’s models/player/humans/group01/male_whatever.mdl

models/player/Group03/male_09.mdl is what you are thinking of.

Yeah, dont use the models/Group03/male_09.mdl model.

Bah now im stuck spawning as Kliener, animations are fine but always Kliener no matter what model you choose.


perhaps it’s not working cause the directory you specified doesn’t exist in my models folder, any clue as to where to find it in the GCF’s or something?

The model I gave you is built into Garrysmod. Must be something else.

Ohh my bad found it in the GCF, so yes it must be something else…

Thanks for all the help guys we got it working now.