Back to Library
Physics Nov 23, 2025

Heal Vehicle

T
by terrorsoul

Restores the health of a vehicle the player is currently in back to the start health

LUA
function HealVehicle(playerId)
    local structure = tm.players.OccupiedStructure(playerId) -- We get the structure the player is currently seated in
    
    if structure ~= nil then
        local blocks = structure.GetBlocks()
        
        for _, block in pairs(blocks) do
            -- Get the original max health of the block
            local maxHp = block.GetStartHealth()
            
            -- Reset current health to max
            block.SetHealth(maxHp)
        end
        
        tm.playerUI.AddSubtleMessageForPlayer(playerId, "REPAIR", "Structure Integrity Restored", 2, "")
    end
end

Discussion

Please log in to post a comment.