I’ve been trying to make a text button where when the player clicks on it they die. Once they click on the text button they will of course die but a timer will also start counting down from 10 too prevent the player from spam clicking the reset text button. Creating a delay feature.
Here is what I have so far which is a script in the text button -
local function timer()
local textbutton = script.Parent
local minutes = 0
local seconds = 10
repeat
if seconds <= 0 then
minutes = minutes - 1
seconds = 59
else
seconds = seconds - 1
end
if seconds < 10 then
textbutton.Text = tostring(minutes)..":0"..tostring(seconds)
else
textbutton.Text = tostring(minutes)..":"..tostring(seconds)
end
wait(1)
until minutes <= 0 and seconds <= 0
end
function onClicked(GUI)
player = script.Parent.Parent.Parent.Parent.Character:findFirstChild("Humanoid")
if (player ~= nil) then
player.Health = 0
timer()
else return end
end
script.Parent.MouseButton1Click:connect(onClicked)
As soon as the player clicks the button they die and the timer starts counting down but as soon as they respawn the timer stops and disappears. I want the timer too keep counting down when the player respawns.
Video of issue -