Why doesnt this work?

Im trying to have the player who activates the command /cop to do all the things. Everything works except for the player model change. It either crashes my game or just doesnt work.

local copr = "0x5E3DA4A4"

RegisterCommand("cop", function()
    SetEntityCoords(GetPlayerPed(-1), 853.1, -1272.95, 30.45, true, false, false, true)
    GiveWeaponToPed(GetPlayerPed(-1), -2084633992, 999, false, false)
    GiveWeaponToPed(GetPlayerPed(-1), 1593441988, 999, false, false)
    GiveWeaponToPed(GetPlayerPed(-1), 487013001, 999, false, false)
    SetPedAsCop(GetPlayerPed(-1), true)
    SetPlayerModel(PlayerId(), copr)
    SetPedArmour(-1, 50)
    Wait(3000)    
    FreezeEntityPosition(GetPlayerPed(-1), true)
    Wait(20000)
    FreezeEntityPosition(GetPlayerPed(-1), false)
end)

Check the example here: SetPlayerModel - FiveM Natives @ Cfx.re Docs

You need to pre-load the model before it can be used.

Edit: Also use PlayerPedId() instead of GetPlayerPed(-1). Much faster. You also only need to set it once usually. In this case set it once at the beginning and then once after the model change (as this changes the handle)

Here is some code where the player can set their model using a command.

Example: /setmodel s_m_y_cop_01

RegisterCommand("setmodel", function(source, args, rawCommand)
	local PlayerPed = PlayerPedId()
	local Model = args[1]
    local ModelHash = GetHashKey(Model)
	
    if IsModelInCdimage(ModelHash) and IsModelValid(ModelHash) then
		RequestModel(ModelHash)
		while not HasModelLoaded(ModelHash) do
			Wait(0)
		end
        SetPlayerModel(PlayerId(), ModelHash)
		SetModelAsNoLongerNeeded(ModelHash)
	end
end, false)

To complete your code, it would be:

RegisterCommand("cop", function(source, args, rawCommand)
	local PlayerPed = PlayerPedId()
	local Model = "s_m_y_cop_01"
    local ModelHash = GetHashKey(Model)
	
    if IsModelInCdimage(ModelHash) and IsModelValid(ModelHash) then
		RequestModel(ModelHash)
		while not HasModelLoaded(ModelHash) do
			Wait(0)
		end
        SetPlayerModel(PlayerId(), ModelHash)
		SetModelAsNoLongerNeeded(ModelHash)
	end
	
	SetEntityCoords(PlayerPed, 853.1, -1272.95, 30.45, true, false, false, true)
	GiveWeaponToPed(PlayerPed, -2084633992, 999, false, false)
	GiveWeaponToPed(PlayerPed, 1593441988, 999, false, false)
	GiveWeaponToPed(PlayerPed, 487013001, 999, false, false)
	SetPedAsCop(PlayerPed, true)
	SetPedArmour(PlayerPed, 50)
	Wait(3000)    
	FreezeEntityPosition(PlayerPed, true)
	Wait(20000)
	FreezeEntityPosition(PlayerPed, false)
end, false)