Problem with setting player model

so when any player clicks a model it only sets the first players model not the player who clicked it

Clientside:



local SCREEN_W, SCREEN_H = 1920, 1080
local _w, _h = ScrW(), ScrH()
local _wMod, _hMod = _w / SCREEN_W, _h / SCREEN_H

function PSetup()
	local dp = vgui.Create("DFrame")
	local ModelIco = vgui.Create("DPanelList", dp)
	local femalel = vgui.Create("DLabel", dp)
	local femalec = vgui.Create("DCheckBox", dp)
	local malel = vgui.Create("DLabel", dp)
	local malec = vgui.Create("DCheckBox", dp)
	local rpname = vgui.Create("DLabel", dp)
	local rpnameT = vgui.Create("DTextEntry", dp)

	dp:SetPos(300 * _wMod, 300 * _hMod)
	dp:SetSize(500 * _wMod, 500 * _hMod)
	dp:SetBackgroundBlur(true)
	dp:ShowCloseButton(false)
	dp:SetDraggable(false)
	dp:MakePopup()

	rpname:SetPos(10 * _wMod, 20 * _hMod)
	rpname:SetColor(Color(0, 0, 0, 255))
	rpname:SetText("RP Name: ")

	rpnameT:SetPos(60 * _wMod, 20 * _hMod)
	rpnameT:SetSize(180 * _wMod, 20 * _hMod)
	rpnameT:SetTextColor(Color(0, 0, 0, 100))
	rpnameT:SetText("Character Name here")
	rpnameT.OnGetFocus = function()
		if(rpnameT:GetText() == "Name.. ") then
			rpnameT:SetTextColor(0, 0, 0, 255)
			rpnameT:SetText("")
		end
	end
	rpnameT.OnEnter = function()

	end

	femalel:SetPos(70 * _wMod, 250 * _hMod)
	femalel:SetColor(Color(0, 0, 0, 255))
	femalel:SetText("Female")

	femalec:SetPos(110 * _wMod, 252 * _hMod)
	femalec:SetChecked(false)
	femalec.OnChange = function()
		if(femalec:GetChecked() == true) then
			ModelIco:Clear()
			female()
		else
			ModelIco:Clear()
			male()
		end

		if(femalec:GetChecked() == true) then
			malec:SetChecked(false)
		elseif(malec:GetChecked() == true) then
			femalec:SetChecked(false)
		end
	end

	malel:SetPos(10 * _wMod, 250 * _hMod)
	malel:SetColor(Color(0, 0, 0, 255))
	malel:SetText("Male")

	malec:SetPos(35 * _wMod, 252 * _hMod)
	malec:SetChecked(false)
	malec.OnChange = function()

		if(malec:GetChecked() == true) then
			ModelIco:Clear()
			male()
		else
			ModelIco:Clear()
			female()
		end

		if(malec:GetChecked() == true) then
			femalec:SetChecked(false)
		elseif(femalec:GetChecked() == true) then
			malec:SetChecked(false)
		end
	end

	function male()
		for k, v in pairs(CitizenModels.m) do
			Mic = vgui.Create("SpawnIcon", ModelIco)
			Mic:SetModel(v)
			ModelIco:AddItem(Mic)
			Mic.DoClick = function(icon)
				surface.PlaySound("ui/buttonclickrelease.wav")
			
				net.Start("changeModel")
					net.WriteString(v)
				net.SendToServer()
			
				dp:SetVisible(false)
				gui.EnableScreenClicker(false)
			end
		end
	end

	function female()
		for k, v in pairs(CitizenModels.f) do
			ic = vgui.Create("SpawnIcon", ModelIco)
			ic:SetModel(v)
			ModelIco:AddItem(ic)
			ic.DoClick = function(icon)
				surface.PlaySound("ui/buttonclickrelease.wav")
			
				net.Start("changeModel")
					net.WriteString(v)
				net.SendToServer()
			
				dp:SetVisible(false)
				gui.EnableScreenClicker(false)
			end
		end
	end


	ModelIco:EnableVerticalScrollbar(true)
	ModelIco:EnableHorizontal(true)
	ModelIco:SetPadding(4)
	ModelIco:SetPos(10 * _wMod, 300 * _hMod)
	ModelIco:SetSize(200, 160)

	gui.EnableScreenClicker(true)

end
concommand.Add("ModelSelect", PSetup)


Serverside:



function ESW:PlayerSetModel(ply)
	net.Receive("changeModel", function(len)
		ply:SetModel(net.ReadString())
	end)
end


anyone got any idea whats going wrong here?

Don’t add the net.Receive inside of a function ( unless the function initializes it ); but that is probably where your issue is. Use just plain-jane net.Receive in a server file without it being inside a function.
Second, don’t trust user input… Set up a shared table, verify the selection on the server, then set the model to the player.

This is how to add a server net.Receive: net.Receive( “name”, function( len, ply ) ply:SetModel( ); end );