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

Im trying to make a delay between clicks but its not working?

Asked by 3 years ago
Edited 3 years ago
local tool = script.Parent
local debounce = false
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://7226679754" --Put your animation id here

if not debounce then

    local track -- Play animation
    tool.Activated:Connect(function()
        track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
        track.Priority = Enum.AnimationPriority.Action
        track.Looped = false
        track:Play()


            debounce = true

            print("anim played")

            wait(0.5)

            debounce = false

    end

)
tool.Unequipped:Connect(function() --Stop animation
    if track then
        track:Stop()
    end
end)

    end

The main part is the debounce all it does is say anim played but i can still spam click and the animation plays every time

1 answer

Log in to vote
0
Answered by 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
local tool = script.Parent
local debounce = false
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://7226679754" --Put your animation id here


local track -- Play animation
tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
        track.Priority = Enum.AnimationPriority.Action
        track.Looped = false
        track:Play()
        print("anim played")
        wait(0.5)
        debounce = false
    end
end)

-- hallo guys welcome to my minecraft

tool.Unequipped:Connect(function() --Stop animation
    if track then
        track:Stop()
    end
end)
0
tysm dude bloxxerboy25 -3 — 3y
0
more questions can be asked on discord, Blue Duck#8344 WINDOWS10XPRO 438 — 3y
Ad

Answer this question