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

Tool use cooldown not working as intended?

Asked by 5 years ago

When the player clicks, it enables a variable bool called "toggle" to true. Then that is supposed to damage the NPC once, but it doesn't. It also doesn't apply the "click to activate toggle". Here's the script.

local weapon = script.Parent.Parent.Handle.HitPart
local dmg = script.Parent.Parent.Interval.Value * 20
local toggle = true

weapon.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then
        if toggle == true then
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            humanoid:TakeDamage(dmg)
            toggle = false
            wait(1)
            toggle = true
        end
    end
end)

It's a server script inside of another server script inside a tool called "Wooden katana".

0
Maybe you should put the line 10 at line 8, line 8 at line 9 and line 9 at line 10? TheRealPotatoChips 793 — 5y
0
that an interesting way to make a cooldown, I use debounce = false instead of toggle = true so maybe try that instead. mantorok4866 201 — 5y
0
@mantorok4866, There is literally no difference. rabbi99 714 — 5y
0
I tried each option, none works. Sensei_Developer 298 — 5y

Answer this question