The title explains it. Im trying to make a delay when the button is pressed it waits 60 seconds until the user can click again. Heres my code. The problem is that if db == true the user can click multiple times and cause the timer to mess up.
local button = script.Parent local player = game.Players.LocalPlayer local bases = workspace.Bases:GetChildren() local base for i,v in pairs(bases)do local owner = v:FindFirstChild("Owner") if owner.Value == player.Name then base = v end end local db = false button.MouseButton1Click:Connect(function() if db == false then db = true game.ReplicatedStorage.Events.Shield:FireServer(player,base) end if db == true then for i = 60, 0 , -1 do script.Parent.Text = "Delay: " .. i wait(1) end db = false end end)