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

how to make this disabeld if u press the button again?

Asked by
hokyboy 270 Moderation Voter
5 years ago
local active = false
script.Parent.MouseClick:Connect(function()
    active = true
    if active == true then
        while true do 
            game.Workspace.Value.Value = game.Workspace.Value.Value + 1
            wait(1)

        end
    end
end)

1 answer

Log in to vote
1
Answered by
sfant43 20
5 years ago
Edited 5 years ago
local active = false
local cooldown = false
script.Parent.MouseClick:Connect(function()
if active == false and cooldown == false then
    active = true
cooldown = true

spawn(function()
wait(0.5)
cooldown = false
end)
spawn(function()
        while true do 
    if active == true then
            game.Workspace.Value.Value = game.Workspace.Value.Value + 1
        end
   wait(1)
    end
end)
end

if active == true and cooldown == false then
active = false
end
end)
Ad

Answer this question