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

I have a cooldown on my move but move decides to skip cooldown?

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local debounce = false
script.Parent.MouseButton1Click:Connect(function()
	if Character.HumanoidRootPart.Anchored == false then
		if debounce == false then

			debounce = true

			if Player.leaderstats.Nature.Value == "Fire" then
				game.ReplicatedStorage.FireWall:FireServer()
			elseif Player.leaderstats.Nature.Value == "Grass" then
				game.ReplicatedStorage.GWall2:FireServer()
			elseif Player.leaderstats.Nature.Value == "Water" then
				game.ReplicatedStorage.WaWalk2:FireServer()
			end
		end
		wait(7)
		debounce = false
	end
end) --This is a local Script BTW

^^^ Here is my code, When I press the button, Sometimes I can use the move multiple times without waiting for the cooldown. Like there is no cooldown at all on the move. Anybody know why?

1 answer

✓ Accepted answer

I am not sure whether it will work or not, but try to keep your debounce in a single if statement. Here's an example :

local debounce = false

if debounce == false then
	debounce = true

	wait(7)
	debounce = false
end

-- And you did 
local debounce = false

if debounce == false then
	debounce = true
end

wait(7)
debounce = false

Lemme know if it helps!

1 comment

0

Ill try this out!

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