script inside the button:
local player = game.Players.LocalPlayer
local char = player.Character
script.Parent.MouseButton1Click:Connect(function()
if char:FindFirstChild(“Humanoid”) then
script.Parent.Text = “Respawning In 9”
wait(1)
script.Parent.Text = “Respawning In 8”
wait(1)
script.Parent.Text = “Respawning In 7”
wait(1)
script.Parent.Text = “Respawning In 6”
wait(1)
script.Parent.Text = “Respawning In 5”
wait(1)
script.Parent.Text = “Respawning In 4”
wait(1)
script.Parent.Text = “Respawning In 3”
wait(1)
script.Parent.Text = “Respawning In 2”
wait(1)
script.Parent.Text = “Respawning In 1”
wait(1)
script.Parent.Text = “Return To Spawn”
char.Head.CFrame = CFrame.new(game.Workspace.SafeZone.Position)
end
end)
Outside of the function, create a variable called “cooldown” or “debounce” and set to false.
Then inside the function you can check with a if statement whether the cooldown is active or not.
If false, make cooldown = true.
At the end of the function after everything is over, make cooldown = false
If true, means cooldown is active
Also, use for loops so that you don’t have to repeat your code so many times.
local player = game.Players.LocalPlayer
local char = player.Character
local Debounce = false
script.Parent.MouseButton1Click:Connect(function()
if char:FindFirstChild(“Humanoid”) and Debounce == false then
Debounce = true
for i = 10, 0, -1 do
wait(1)
script.Parent.Text = (“Respawning In ”..i)
end
Debounce = false
script.Parent.Text = “Return To Spawn”
char.Head.CFrame = CFrame.new(game.Workspace.SafeZone.Position)
end
end)