What do you want to achieve? I want to make my animation move on my tool.
What is the issue? My Script won’t work. Here it is:
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local Animation = script.Parent:FindFirstChild("Attack")
local AttackAnimation = character.Humanoid:LoadAnimation(Animation)
local CanAttack = true
local debounce = 0.5
script.Parent.Activated:Connect(function()
if CanAttack then
CanAttack = false
AttackAnimation:Play()
wait(debounce)
CanAttack = true
end
end)
and here’s a screenshot of how the parents look (i haven’t gotten to making it hit yet so that might be the case):
Make sure that the animation prioty is setted to Action. If that did not work, try changing the script to: local character = player.Character or player.CharacterAdded:Wait()
If that one did not also work, try moving the AttackAnimation variable inside the function.
Make sure that the animation prioty is setted to Action .
This is most likely the reason if there is nothing in your output, because from what I can tell, the code you provided works fine. If the animation is NOT set to action, then it plays, and then is overrided by another animation and thus, makes it not work in your case.
All good, we learn from our mistakes, correct? That’s what happens in coding. Don’t you love the small issues which ruin big projects welp, at least you found the solution, congrats.
welp, i tried out the other solution and it didn’t work, i tried this one and it didn’t work too, its probably something about the animation or i’m writing the code wrong…
It’s either a problem on roblox’ end or you’re doing something wrong with the animation object, I don’t think you might be putting the animation id in correctly, or there’s just a general issue or glitch on your side.
I was just testing it out on the rig so i kinda forgot lol.
BTW, this is the script right now, i decided to do some changes like getting rid of debounce and changing it based on what people said, i feel like i wrote something wrong
local player = game:GetService("Players").LocalPlayer
local Character = player.character or player.CharacterAdded:wait()
local Animation = script.Parent:FindFirstChild("Attack")
local AttackAnimation = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
local CanAttack = true
script.Parent.Activated:Connect(function()
if CanAttack then
CanAttack = false
AttackAnimation:Play()
wait(1)
CanAttack = true
end
end)
So I just tested your script out and it works perfectly fine for me, odd. I recommend turning off the tools RequireHandle property just incase nothing has worked. Otherwise I wouldn’t know what the problem was, it all works fine for me. https://gyazo.com/8b348412ad491781aab7f52099276b31