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

Why Isn't debounce not working as Intended? Its suppose to work but It doesn't (?)

Note: I did these In the pass and they work, just don't know why this doesn't

I made a debounce that prevent the player from spamming the tool via a RemoteEvent, but as the title says, the debounce refuse to stop the player from spamming

Script:

local tool = script.Parent
local Debounce = false

tool.Activated:Connect(function()
	if Debounce == false and tool.Parent.IsStun.Value == true then
		Debounce = true
		tool.RemoteEvent:FireServer()
		wait(5)
		Debounce = false
	end
end)

4 comments

0

The debounce will only stop the remote event from firing, not the tool from activating. if you want to disable the tool when debounce is active, you can set tool.Enabled.

0

Alright

0

But why Isn't the debounce stopping the tool from activating, and how can I stop It from stopping the event and actually stop the tool activation without using Tool.Enabled?

0

Oh and by the way, the script Is a local script Inside of a tool

1 answer

✓ Accepted answer

Idk if this will work, but try it.

local tool = script.Parent
local Debounce = false

tool.Activated:Connect(function()
    if Debounce then return end

    if tool.Parent.IsStun.Value then
        Debounce = true
        tool.RemoteEvent:FireServer()
        wait(5)
        Debounce = false
    end
end)

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