When this event is triggered the player respawn normally but he can't do anything except typing in the chat. so the player is kinda freezed? I am trying to fix this, but i can't get it to work. Can someone help?

RegisterNetEvent(‘uptime:revive’)
AddEventHandler(‘uptime:revive’, function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

TriggerServerEvent('esx_ambulancejob:setDeathStatus', false)

Citizen.CreateThread(function()
    DoScreenFadeOut(800)

    while not IsScreenFadedOut() do
        Citizen.Wait(50)
    end

    local formattedCoords = {
        x = ESX.Math.Round(coords.x, 1),
        y = ESX.Math.Round(coords.y, 1),
        z = ESX.Math.Round(coords.z, 1)
    }

    ESX.SetPlayerData('lastPosition', formattedCoords)

    TriggerServerEvent('esx:updateLastPosition', formattedCoords)

    RespawnPed(playerPed, formattedCoords, 0.0)

    TriggerEvent('esx_ambulancejob:heal', 'big', true)

    StopScreenEffect('DeathFailOut')
    DoScreenFadeIn(800)
end)

end)

function RespawnPed(ped, coords, heading)
–SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
–NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
SetPlayerInvincible(ped, false)
–TriggerEvent(‘playerSpawned’, coords.x, coords.y, coords.z)
ClearPedBloodDamage(ped)

ESX.UI.Menu.CloseAll()

end

it shows no errors in the server console or on client console

This is client code yes?
Also in the script we actively use we have NetworkResurrectLocalPlayer(playerPos, true, true, false) not NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false). Try playing around with this native execution and see if that helps at all.

I tried this but the player keeps freezing when he is respawned

I saw this in another ESX script. Try adding the following to your revive function;

ClearPedBloodDamage(ped)
ClearPedLastDamageBone(ped)
ClearPedTasks(ped)

TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn')