Tutorial 2026-02-19

FiveM Death & Respawn System - Complete Guide

OntelMonke

OntelMonke

Admin & Developer at Agency Scripts

Detecting Player Death

The death and respawn system is one of the most fundamental mechanics on any FiveM roleplay server, governing what happens when a player's health reaches zero and how they return to gameplay. GTA V's default death behavior involves an automatic respawn at the nearest hospital after a brief cinematic, which completely breaks roleplay immersion. To build a proper system, you need to intercept the death state before the game's default handler takes over. Monitor the player's health every frame using GetEntityHealth and detect when it drops to the death threshold, which is 0 for peds. When death is detected, immediately use NetworkResurrectLocalPlayer to prevent the default death screen from appearing, then set the player into a ragdoll state using SetPedToRagdoll to simulate being incapacitated. Disable the default respawn system by calling SetPlayerInvincible temporarily while you transition into your custom death state handler. This approach gives you complete control over the death experience while maintaining visual realism.

The Bleedout Timer System

The bleedout timer creates a critical window between being downed and being fully dead, during which other players can interact with the incapacitated person. When a player enters the downed state, start a countdown timer that represents them slowly bleeding out. Display this timer prominently on screen through an NUI overlay showing the remaining time and relevant instructions. During the bleedout phase, the player should be in a ragdoll or crawling animation on the ground, unable to use weapons, drive vehicles, or interact with most world objects. Allow downed players to use proximity voice chat so they can call for help or roleplay their injuries. The timer duration should be configurable, typically between 5 and 15 minutes, and long enough for EMS to realistically respond. Implement a system where the timer accelerates if the player takes additional damage while downed, and slows or pauses if another player begins applying first aid items like bandages or a medical kit.

-- Client-side death state management
local isDead = false
local bleedoutTime = Config.BleedoutDuration -- seconds
local bleedoutTimer = 0
local lastStandUsed = false

CreateThread(function()
    while true do
        local ped = PlayerPedId()
        local health = GetEntityHealth(ped)

        if health <= 0 and not isDead then
            isDead = true
            bleedoutTimer = bleedoutTime
            lastStandUsed = false

            -- Prevent default death
            NetworkResurrectLocalPlayer(
                GetEntityCoords(ped), GetEntityHeading(ped),
                true, false
            )
            SetEntityHealth(ped, 1)
            SetEntityInvincible(ped, true)
            SetPedToRagdoll(ped, -1, -1, 0, false, false, false)
            ClearPedTasks(ped)

            -- Notify server
            TriggerServerEvent('death:playerDowned', GetEntityCoords(ped))

            -- Show death UI
            SendNUIMessage({ action = 'showDeathScreen', timer = bleedoutTimer })
        end

        if isDead then
            bleedoutTimer = bleedoutTimer - 1
            SendNUIMessage({ action = 'updateTimer', timer = bleedoutTimer })

            -- Disable controls while downed
            DisableControlAction(0, 22, true)  -- jump
            DisableControlAction(0, 24, true)  -- attack
            DisableControlAction(0, 25, true)  -- aim
            DisableControlAction(0, 75, true)  -- exit vehicle

            if bleedoutTimer <= 0 then
                -- Fully dead - offer respawn options
                SendNUIMessage({ action = 'showRespawnOptions' })
            end
        end

        Wait(isDead and 1000 or 500)
    end
end)

Last Stand Mechanic

The last stand mechanic gives downed players a brief opportunity to fight back or crawl to safety, adding a tactical layer to combat encounters. When a player first goes down, offer them a one-time activation that puts them in a prone position where they can fire a sidearm with heavily reduced accuracy and movement speed for 15-30 seconds before collapsing fully. Implement this by placing the player in a crawling animation using TaskPlayAnim with a ground-based animation dictionary, then temporarily re-enabling weapon usage but restricting it to pistols only. Apply a heavy weapon sway effect using camera manipulation to simulate the difficulty of aiming while mortally wounded. The last stand should drain the bleedout timer faster as the exertion accelerates blood loss. Display visual indicators like screen desaturation, vignette effects, and a heartbeat sound that slows over time to create tension. This mechanic should only be available once per death cycle to prevent abuse, and it should be disabled entirely if the player was killed by a headshot, representing an instantly incapacitating wound.

EMS Interaction and Revival

The EMS revival system is where the death mechanic creates meaningful roleplay interactions between the downed player and emergency medical services. When an EMS player approaches a downed player, they should see an interaction prompt that initiates a treatment sequence. The treatment process should take a realistic amount of time, typically 10-20 seconds, during which the EMS player performs a medical animation and cannot move or defend themselves, creating vulnerability that adds stakes to emergency responses in dangerous areas. Implement multiple treatment tiers: basic stabilization that stops the bleedout timer from progressing, advanced treatment that begins slowly restoring health, and full revival that returns the player to a standing state with partial health. Each tier should require specific medical items from the EMS player's inventory, such as bandages for stabilization, a medical kit for treatment, and adrenaline for revival. After revival, apply a temporary debuff where the player has reduced maximum health and stamina for several minutes, representing recovery from near-death injuries that discourages immediately jumping back into combat.

-- Server-side EMS revival handler
RegisterNetEvent('death:attemptRevive')
AddEventHandler('death:attemptRevive', function(targetId, treatmentType)
    local src = source
    local emsPed = GetPlayerPed(src)
    local targetPed = GetPlayerPed(targetId)

    if not emsPed or not targetPed then return end

    -- Check distance
    local emsCoords = GetEntityCoords(emsPed)
    local targetCoords = GetEntityCoords(targetPed)
    if #(emsCoords - targetCoords) > 3.0 then return end

    -- Check if EMS has required items
    local requiredItems = Config.TreatmentItems[treatmentType]
    for _, item in ipairs(requiredItems) do
        if exports.ox_inventory:Search(src, 'count', item.name) < item.count then
            TriggerClientEvent('ox_lib:notify', src, {
                title = 'Missing supplies',
                description = 'You need: ' .. item.label,
                type = 'error'
            })
            return
        end
    end

    -- Remove items and start treatment
    for _, item in ipairs(requiredItems) do
        exports.ox_inventory:RemoveItem(src, item.name, item.count)
    end

    -- Trigger animations on both players
    TriggerClientEvent('death:startTreatmentAnim', src, targetId)
    TriggerClientEvent('death:receivingTreatment', targetId, src, treatmentType)

    -- After treatment duration, revive
    SetTimeout(Config.TreatmentDurations[treatmentType], function()
        TriggerClientEvent('death:revived', targetId, treatmentType)
        TriggerClientEvent('death:treatmentComplete', src)
    end)
end)

Hospital Respawn System

When the bleedout timer expires without EMS intervention or the player chooses to give up, the hospital respawn system handles returning them to gameplay. Present the player with a death screen NUI that shows two options: wait for EMS with a visual indicator of nearby on-duty medics, or respawn at the nearest hospital for a fee. The hospital respawn should not be instant. Apply a loading animation or fade to black transition, then teleport the player to the hospital interior with a waking-up-in-bed animation using an appropriate hospital room interior and bed prop. Charge a medical bill that scales with the player's current financial situation, taking a percentage of their cash on hand rather than a flat fee, which prevents the cost from being trivial for wealthy players and devastating for newcomers. After hospital respawn, apply an injury cooldown period where the player has reduced stats and is visually wearing a hospital gown before they can change clothes. Track death frequency to implement a soft penalty where players who die very frequently within a short timeframe face increasing respawn costs and longer recovery periods, discouraging reckless behavior without making death feel overly punishing for occasional incidents.

Death Screen UI Design

The death screen is the primary interface players see during their most vulnerable gameplay moment, so it needs to be clean, informative, and atmospheric. Build it as an NUI overlay that takes control of the screen when the player enters the downed state. Apply a gradual desaturation filter that removes color from the game world, a subtle red vignette around the screen edges that pulses with a heartbeat rhythm, and a slight blur effect that intensifies as the bleedout timer decreases. Display the remaining bleedout time as a prominent countdown in the center or top of the screen, along with action prompts: press E to call for help via the in-game phone, hold G to activate last stand if available, or hold X to give up and respawn at the hospital. Show a notification when EMS is en route with an estimated arrival time, and display the names and distances of nearby players who could potentially help. Keep the UI minimal and avoid cluttering the screen with unnecessary information during what should be a tense, immersive moment. Use subtle GSAP animations for the UI elements fading in and the timer counting down to maintain visual polish.

Injury and Recovery System

Extend the death system with an injury layer that persists after revival to add depth and consequences. When a player is revived by EMS or respawns at the hospital, assign injury effects based on the cause of death. Gunshot wounds cause a limp animation that reduces movement speed by 20% for 15 minutes. Vehicle crashes apply a dazed effect with periodic screen shake for 10 minutes. Falls from height cause a leg injury that prevents sprinting. Drowning causes a cough animation and reduced stamina. Store active injuries in the player's state bag so they persist across script restarts and are visible to other players. Create an injury treatment pathway where players can visit a doctor NPC or player pharmacist to receive medication that reduces the duration of injury effects. Implement a pain system where severe injuries cause occasional screen flinches and suppressed groaning sounds that nearby players can hear, creating opportunities for concerned citizens or predatory criminals to identify and interact with recently injured players. The injury system bridges the gap between death and full recovery, making each death a multi-phase experience that extends roleplay rather than being a momentary inconvenience.

Configuration and Admin Controls

A flexible death system needs comprehensive configuration options and administrative tools. Provide server owners with a config file that controls every timing aspect: bleedout duration, last stand duration and availability, hospital respawn cost formula, EMS treatment durations per tier, injury effect durations per type, and the cooldown between deaths before escalating penalties apply. Add admin commands that allow staff members to instantly revive a player, kill a player for administrative purposes, adjust a specific player's bleedout timer, clear all active injuries, and toggle god mode for events or administrative situations. Build a death log that records every player death with the timestamp, location coordinates, cause of death, killer identifier if applicable, response time of EMS, and whether the player was revived or respawned. Expose this log through your admin panel so staff can investigate suspicious patterns like repeated deaths in the same location indicating a spawn camp, or unusually fast revivals suggesting EMS abuse. The death system should emit events that other scripts can hook into, allowing your job system to notify on-duty EMS of nearby downed players and your police system to flag locations with frequent violent deaths.

Share this article

Ready to upgrade your server?

Check out our premium FiveM scripts in the Agency Scripts store or join our Discord community for support and updates.