How do I check if a player died, then after they die, they’re lives goes down by 1?
Example
local Lives = 5
stuff I dont know function thing
local Lives = Lives - 1 -- I think I did this right idk
if Lives == 0 then
set player onto dead team
end
end)
get their humanoid and detect deaths with the humanoid.Died event
local lives = 5
humanoid.Died:Connect(function()
lives -= 1 --remove 1 life
end)
You can use this article for reference:
https://developer.roblox.com/en-us/api-reference/event/Humanoid/Died
You can add a function when a player joins:
local lives = 5
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
lives -= 1
end)
end)
end)