Simple join script

basically im trying to spawn a vehicle on join, and change the model of the player at the same time. For some reason its crashing my game.

AddEventHandler('playerSpawned', function(spawn)
    Citizen.CreateThread(function()
        local model = "zentorno"
        local model1 = "s_m_y_cop_01"
        
        
        if IsModelValid(model) and IsModelValid(model1) then
            RequestModel(model)
            RequestModel(model1)
            
            while HasModelLoaded(model) == false and HasModelLoaded(model1) == false do
                Citizen.Wait(10)
            end
            
            local vehicle = CreateVehicle(model, GetEntityCoords(PlayerPedId()), 0, true, false)
            
            SetPedIntoVehicle(PlayerPedId(), vehicle, -1)
            SetPlayerModel(PlayerId(), model1)
        else
        end
    end)
end)

Could someone help? :wink:

I think it has to be the hash, try this:

AddEventHandler('playerSpawned', function(spawn)
    Citizen.CreateThread(function()
        local model = GetHashKey("zentorno")
        local model1 = GetHashKey("s_m_y_cop_01")
        
        
        if IsModelValid(model) and IsModelValid(model1) then
            RequestModel(model)
            RequestModel(model1)
            
            while HasModelLoaded(model) == false and HasModelLoaded(model1) == false do
                Citizen.Wait(10)
            end
            
            local vehicle = CreateVehicle(model, GetEntityCoords(PlayerPedId()), 0, true, false)
            
            SetPedIntoVehicle(PlayerPedId(), vehicle, -1)
            SetPlayerModel(PlayerId(), model1)
        else
        end
    end)
end)

@Scott_UK Game is still crashing, i have no mods installed.