Animation not working?

I left Roblox for a few months but now I’m back. I’m a little rusty, though, because something’s weird with my script.

script.Parent.Activated:Connect(function()

local anim = game.Players.LocalPlayer.Character.Humanoid.Animator:LoadAnimation(script.Parent.Animation)

anim:Play()

end)

The animation does not work.

This is a group game and the animation is under the group. This is a local script in the root of a tool. I don’t understand what’s gone wrong. There are no errors in the output.

Thanks.

I’ve never tried using

Humanoid.Animation:LoadAnimation()

Maybe try using instead.

Humanoid:LoadAnimation()

Implemented on your code:

script.Parent.Activated:Connect(function()
    local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
    anim:Play()
end)

Humanoid.Animator is the new way to do it. Humanoid.LoadAnimation was deprecated a while ago. Also, I tried using humanoid.loadanimation before, and it still didn’t work.

I still use Humanoid:LoadAnimation() and it works.
Also its not Humanoid.LoadAnimation its Humanoid:LoadAnimation()

If your animation still isnt working then recheck it.

  • Animation should be owned by same creator.
  • If its a tool the animation priority should set to Action.
  • Animation should be animated correctly.

Here is a shot in the dark, but maybe try looking for the humanoid in the character before running the rest of the script… it might be trying to run the animation before the character is found.

Is their an error in the console like ClipService failed to load?

This bug is a critical bug that still hasn’t been fixed but can be avoided.

It works, but it’s deprecated. Roblox literally recommends you don’t use it. It is owned by the group. The animation works. It is set to Action.

@RMofSBI There are no errors in the console, and everything is in the Activated function, so it shouldn’t run unless the player is loaded.

@kaiumber4 There are no errors in the console.

i’m not sure you can get the player from a tool, i’ve tried doing it before and it just errored, try finding a humanoid in the tool’s parent

workspace:WaitForChild(game.Players.LocalPlayer.Name, 100)

add this at the top of your script.

but you said the function isn’t running… im confused.

I tried, it still doesn’t work.

@RMofSBI The function runs, I even tested a print block in it and it works. The problem is the animation.

Try loading in the animation ID directly (“rbxassetid://number here”)… this was the hiccup for someone’s similar issue the other day.

I think that would work as the character (which contains a humanoid) doesn’t load in right away. Try doing, when getting both the character and humanoid a WaitForChild()

The script isn’t running right away. It runs when the tool is activated.