ply:SetModel doesn't seem to work on the client

I’m trying to make a model panel that sets your model. problem is that when it sets it, it only shows up different in the DModelPanel I made. I’ve asked people what my model looks like and they say it looks the same. any solutions?
Code:
[lua]concommand.Add(“model_menu”,function(ply)
local modelframe = vgui.Create(“DFrame”)

modelframe:Center()
modelframe:SetSize(220,200)
modelframe:SetTitle("Models")
modelframe:MakePopup()

local IconList = vgui.Create( "DPanelList", modelframe ) 

IconList:EnableVerticalScrollbar( true ) 
IconList:EnableHorizontal( true ) 
IconList:SetPadding( 4 ) 
IconList:SetPos(10,30)
IconList:SetSize(200, 160)

for k,v in pairs(Models) do     
  local icon = vgui.Create( "SpawnIcon", IconList )        
  icon:SetModel( v )
  icon:SetToolTip( v )
  IconList:AddItem( icon )     
  icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" )  
	ply:SetModel(v) end      
end

end)[/lua]

So, set it serverside?

it’s shared, forgot to say that.

[editline]06:03PM[/editline]

I also have it in an if (CLIENT) statement.

Well, then it obviously works as expected and only changes the model for you (clientside). If you want other people to see the new model, you need to change it serverside.

How would I do that? Maybe a concommand?

[editline]06:22PM[/editline]

I was thinking something like this:
[lua]concommand.Add(“model_menu”,function(ply)
local modelframe = vgui.Create(“DFrame”)

modelframe:Center()
modelframe:SetSize(220,200)
modelframe:SetTitle("Models")
modelframe:MakePopup()

local IconList = vgui.Create( "DPanelList", modelframe ) 

IconList:EnableVerticalScrollbar( true ) 
IconList:EnableHorizontal( true ) 
IconList:SetPadding( 4 ) 
IconList:SetPos(10,30)
IconList:SetSize(200, 160)

for k,v in pairs(Models) do     
  local icon = vgui.Create( "SpawnIcon", IconList )        
  icon:SetModel( v )
  icon:SetToolTip( v )
  IconList:AddItem( icon )     
  icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" )  
	ply:RunConsoleCommand("Model",v) end      
end

end)
end
concommand.Add(“Model”,function(p,c,a)
p:SetModel(a[1])
end)
[/lua]

Yeah, that should work. Put some checks in the console command and you’re good to go.

Also, if you are putting this into a shared file, make sure that you enclose the last concommand.Add with an “if (SERVER) then” statement, to make sure it is only defined on the server; but I guess you already knew that :wink: