Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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)

This discussion is preserved as it was. New answers, comments, and votes are closed.