(Solved) Is there anyway to change skin/model with a command WITHOUT using [ES]

Please don’t laugh at me, I am fairly new to lua and I am learning more everyday. I tried this and it don’t work.

—server—
elseif(command[1] == “/cop1” and tonumber(Users[GetPlayerName(source)][‘admin’]) >= 1) then
TriggerClientEvent(“sheriff”, source)

—client—
RegisterNetEvent(“sheriff”)
AddEventHandler(“sheriff”, function()
then SetPlayerModel(playerId(), “s_m_y_sheriff_01”)

end)

You are quite almost there.

However, the model has to be hashed and loaded before it can be assigned to the player. So your client should look like this instead.

RegisterNetEvent("sheriff")
AddEventHandler("sheriff", function()

-- Get the ped of the player.
local myPed = GetPlayerPed(-1)

    -- Create a thread.
    Citizen.CreateThread(function()
	
        -- Not neccesary, but set model as variable.
        local model = "s_m_y_sheriff_01"
        
        -- Get model hash.
	    local modelhashed = GetHashKey(model)
    
        -- Request the model, and wait further triggering untill fully loaded.
	    RequestModel(modelhashed)
	    while not HasModelLoaded(modelhashed) do 
	    	RequestModel(modelhashed)
	    	Citizen.Wait(0)
	    end
        -- Set playermodel.
		SetPlayerModel(PlayerId(), modelhashed)
        -- Set model no longer needed.
		SetModelAsNoLongerNeeded(modelhashed)
	end)
end)
3 Likes

@asser90 you sir, are a boss! many thanks! because of ppl like you I can look at the code and get a better understanding. works like a charm!

You’re very welcome mate.