local bowanimationr6 = script:WaitForChild("bowanimationr6")
local Tool = script.Parent
Tool.Activated:Connect(function()
local Character = Tool.Parent
if Character then
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and bowanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(bowanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
LoadedAnim:Play()
end
end
end
end)
I’m not completely sure, but I believe it would be like this:
local debounce = false
local Tool = script.Parent
Tool.Activated:Connect(function()
if debounce == false then
local Character = Tool.Parent
if Character then
local Humanoid = Character:WaitForChild(“Humanoid”)
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and bowanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(bowanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
LoadedAnim:Play()
local debounce = true
end
end
end
end)
I’m not a pro at scripting, if I did it wrong, at least I tried to help with what I know.
local debounce = false
local Tool = script.Parent
Tool.Activated:Connect(function()
if debounce == false then
local debounce = true
local Character = Tool.Parent
if Character then
local Humanoid = Character:WaitForChild(“Humanoid”)
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and bowanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(bowanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
LoadedAnim:Play()
local debounce = false
end
end
end
end)
If I’m not mistaken it should be something among the lines of
local debounce = false
local bowanimationr6 = script:WaitForChild("bowanimationr6")
local Tool = script.Parent
Tool.Activated:Connect(function()
local Character = Tool.Parent
if Character then
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and bowanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(bowanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
LoadedAnim:Play()
end
debounce = true
wait(--change this to however long your debounce should be)
debounce = false
end
end
end)
I hvent tested it so just try it and move around the debounce (but keep debounce = true wait(--change this to however long your debounce should be) debounce = false together so it doesn’t mess up. Let me know how it goes : D
A while ago, I had the same situation with adding debounces.
This was the Solution to my problem.
The reason why @loxergenius 's solution isn’t working because on line 6 & 23, it wasn’t changing the Debounce variable from line 1. Instead, it is creating new variables.
local debounce = false
local Tool = script.Parent
Tool.Activated:Connect(function()
if debounce == false then -- checks if Debounce is on
debounce = true -- activates Debounce
local Character = Tool.Parent
if Character then
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and bowanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(bowanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
LoadedAnim:Play()
end
end
end
task.wait() -- duration of debounce
debounce = false -- makes it so it can be activated once duration has pasted
end
end)
You should always tab your code properly. Posting unindented code to help forums will get you yelled at (well, hopefully not here…) Studio will do automatically, too:
Ctrl+A selects all your code
Alt+Shift+F automatically formats it with indentation
local Tool = script.Parent
local newestvaxanimationr6 = Tool:WaitForChild("newestvaxanimationr6", 1)
local debounce = false
Tool.Activated:Connect(function()
if debounce then
return
end
local Character = Tool.Parent
if Character then
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 and newestvaxanimationr6 then
local LoadedAnim = Humanoid:LoadAnimation(newestvaxanimationr6)
repeat
task.wait()
until LoadedAnim.Length > 0
debounce = true
LoadedAnim:Play()
end
end
end
task.wait(5)
debounce = false
end)
I responded to the other thread, this is how a debounce is and should be achieved.
This wouldn’t work as you’re not doing anything with the debounce variable, you’re just setting it to false and true but nowhere in the script is the value of the variable being checked.