Untitled

 avatar
unknown
plain_text
2 years ago
438 B
2
Indexable
local player = game.Players.LocalPlayer

local maxHealth = 100
local currentHealth = maxHealth

function onHit(damage)
currentHealth = currentHealth - damage
if currentHealth <= 0 then
die()
end
end

function die()
-- add code here to handle player death
end

function onSpawn()
currentHealth = maxHealth
end

-- connect the functions to events
player.CharacterAdded:Connect(onSpawn)
player.Character.Humanoid.HealthChanged:Connect(onHit)
Editor is loading...