Hello, I am working on a timer, but when the player dies and respawns the timer wont run again heres the code i am using , please let me know if you need more info
PS sorry for the messy code
local timer
game.Players.PlayerAdded:Connect(function(player)
timer = player.PlayerGui:WaitForChild("ScreenGui").TextLabel
print(player.Parent)
print(player)
end)
local mill = 00
local sec = 00
local min = 00
local start = false
local function timerStart()
while start == true do
wait(0.0455)
mill = mill + 5
if mill >= 100 then
mill = mill - 100
sec = sec + 1
end
if sec >= 60 then
sec = sec - 60
min = min + 1
end
if mill <= 9 then
timer.Text = min..":"..sec..":".."0"..mill
end
if sec <= 9 then
timer.Text = min..":".."0"..sec..":"..mill
end
if min <= 9 then
timer.Text = "0"..min..":"..sec..":"..mill
end
if mill <= 9 and sec <= 9 then
timer.Text = min..":".."0"..sec..":".."0"..mill
end
if mill <= 9 and min <= 9 then
timer.Text = "0"..min..":"..sec..":".."0"..mill
end
if min<= 9 and sec <= 9 then
timer.Text = "0"..min..":".."0"..sec..":"..mill
end
if min <= 9 and sec <= 9 and mill <= 9 then
timer.Text = "0"..min..":".."0"..sec..":".."0"..mill
end
end
end
workspace.Start1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if timer.Text ~= "00:00:00" then
mill = 00
sec = 00
min = 00
end
start = true
timer.TextColor3 = Color3.new(0.172549, 0.92549, 0.262745)
timer.TextTransparency = 0
workspace.Start1.CanTouch = true
timerStart()
workspace.Start1.CanTouch = false
workspace.Finish1.CanTouch = true
wait(3)
end
end)
workspace.Finish1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
timer.TextColor3 = Color3.new(1, 0.576471, 0.294118)
start = false
workspace.Start1.CanTouch = true
workspace.Finish1.CanTouch = false
end
wait(3)
end)
workspace.Death.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
timer.TextColor3 = Color3.new(1, 0.576471, 0.294118)
start = false
workspace.Start1.CanTouch = true
workspace.Finish1.CanTouch = false
end
wait(3)
end)