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)