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

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

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

✓ Accepted 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)

2 comments

0

tysm dude

0

more questions can be asked on discord, Blue Duck#8344

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