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

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

Asked by 1 year ago

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)
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. sergeant_ranger 184 — 1y
0
Alright imnotaguest1121 362 — 1y
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? imnotaguest1121 362 — 1y
0
Oh and by the way, the script Is a local script Inside of a tool imnotaguest1121 362 — 1y

1 answer

Log in to vote
1
Answered by 1 year ago

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)
Ad

Answer this question