Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make textbutton not clickable?

Asked by 4 years ago

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)
0
You could use the Active property in the TextButton, and make it so when they click, it sets Active to false until the debounce is over. JoshGamingHQ1 43 — 4y

Answer this question