I’m trying to make it where if a local player dies something will happen. In this case I have a timer and am trying to make it where whenever the player dies the timer will reset.
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Health = Char:WaitForChild("Humanoid").Health
local function teleport()
local clonedgui = Player.PlayerGui:WaitForChild("Timer")
local minutes = 0
local seconds = 16
repeat
if seconds <= 0 then
minutes = minutes - 1
seconds = 59
else
seconds = seconds - 1
end
if seconds < 10 then
clonedgui.TextLabel.Text = tostring(minutes)..":0"..tostring(seconds)
else
clonedgui.TextLabel.Text = tostring(minutes)..":"..tostring(seconds)
end
if Health < 1 then
local minutes = 0
local seconds = 16
end
wait(1)
until minutes <= 0 and seconds <= 0
end
Here I have a script which doesn’t seem to be working because whenever the player dies the timer doesn’t reset, instead it just keeps going on. I thought “if health < 1 then” or “if health == 0 then” would work but none of those options seem to be working. By the way I am using a local script in StarterPlayerScripts. Thanks.