I made an animation for my axe using moon animator, but it won’t load. Please help!
Here’s my script:
local Tool = script.Parent
local Axeanim = Tool.Axeanim
Tool.Equipped:Connect(function(Mouse)
Tool.Activated:Connect(function()
local Character = Tool.Parent
local AnimationTrack = Character.Humanoid:LoadAnimation(Axeanim)
AnimationTrack:Play()
end)
end)
```
Roblox deprecated the use of Humanoid:LoadAnimation() recently as it was changed to a new efficient method.
The method I have listed below is a way more efficient way of doing what you’re trying to do.
You don’t need to connect a new .Activated event every time the tool is equipped, this could lead to memory loss and leaks.
I hope this script works, if it doesn’t be sure to pop me an @ and I’ll help again
Also, you don’t need to use a Server Script to perform an animation as it automatically updates to the server.
Best to use a local script!
In future, please do read up on the Creator Documentation roblox provides that will answer these questions for you.
When roblox deprecates a method they will always provide a newer method for use, which again is always listed on the docs.
local Tool = script.Parent
local Axeanim = Tool.Axeanim
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Track = Animator:LoadAnimation(Axeanim)
Tool.Activated:Connect(function()
Track:Play()
end)
if it is an idle animation i ran into this problem too
the toolnone animations in the default animate script will overwrite idle animations for some reason. so now if you want to use an idle animation for a tool you will need to set the toolnone’s animation id when equipped, just make sure to set it back once unequipped