I’m trying to make an axe and part of it is playing an animation when the player hits the tree. It isn’t working, despite the rest of the axe working completely fine and not giving out any errors. I looked up solutions on the devforum but from what I’ve read they were all outdated and were solved by using Animator, which I already am.
Below is the code I use to load the animation in a local script:
local function cut()
if debounce or not mouse.Target then return end
if mouse.Target:IsA("BasePart") and mouse.Target.Name == "TreeTrunk" then
local distance = (mouse.Target.Parent.PrimaryPart.Position - tool.Parent:FindFirstChild("HumanoidRootPart").Position).Magnitude
if distance < 10 then
print(distance)
debounce = true
action:FireServer("Damage", mouse.Target)
local animator = tool.Parent:FindFirstChildWhichIsA("Humanoid"):FindFirstChildOfClass("Animator")
animator:LoadAnimation(tool.Chop)
task.wait(tool:GetAttribute("Cooldown"))
debounce = false
end
end
end