local tool = script.Parent
local usable = true
tool.Equipped:Connect(function()
tool.Activated:Connect(function(plr)
print("clicked")
if plr.Humanoid.Health ~= 0 then
if usable == true then
local hum = plr.Humanoid
usable = false
local anim = Instance.new("Animation")
anim.AnimationId = "*My animation ID*"
local track = hum:LoadAnimation(anim)
track:Play()
wait(2.5)
tool:Destroy()
end
end
end)
end)
The script works normally, but it just skips the animation. I made the animation in Moon animator
It is server script
I tried to fix it several times, but nothing worked.
First of all loading animations to the humanoid is deprecated. You should instead load it to the Animator inside of the humanoid. If switching to loading via the animator doesn’t work then try adjusting the animation priority. Typically if the animation priority is too low it might not play.
You could adjust your code to utilize:
local track = hum.Animator:LoadAnimation(anim)
This assumes you have an animator inside of your humanoid. Make sure to add handling for if there isn’t one.
There are a few issues.
The first is that you’re connecting events in connections, which isn’t ideal. It wouldn’t cause the issue tho.
Another is that your creating a new animation track every time you use the tool. You should make the animation on the top of the script instead.
The problem is that usable is never set back to true, and therefore you can only use it once. If that’s what you wanted, then I don’t know why it won’t play.
Also another overlooked issue is if the animation is r6 or r15. I was trying to load an r6 animation into an r15 animation and it didnt work but when I changed the game to r6 it worked like butter, so make sure to double check what the animation type is and what your game type is.