Animation not playing

  1. What do you want to achieve?
    For the animation to play on a loop

  2. What is the issue?
    The Animation does not play, there aren’t any errors or warnings, either.

  3. What solutions have you tried so far?
    This is basically based of the Dev Hub’s code example so it’s not really solvable that way.

local animator = Instance.new("Animator", script.Parent)
local animation = Instance.new("Animation", animator)

animation.AnimationId = "rbxassetid://9495604116"

while true do
	animator:LoadAnimation(animation):Play()
	animator.AnimationPlayed:Wait()
end

1 Like

LoadAnimation() requires the AnimationId, so it would need to be,
animator:LoadAnimation(9495604116)

I did that previously and it kept erroring this:

Unable to cast value to Object - Server - Script:7

LoadAnimation() doesn’t require AnimationId, but the Animation object itself.

You can set the AnimationTrack.Looped to true if you want to repeat this, rather using a loop.

1 Like

That’s what my original code is doing?

what is the script parented to?

The model’s Humanoid. Yes, it’s a properly built rig.

Yes, but it’s rather not efficient. AnimationTrack has a property called Looped which will loop itself without a loop function. For example:

local animationTrack = animator:LoadAnimation(animation):Play()
animationTrack.Looped = true
animationTrack:Play() -- will repeat itself automatically

Oh. I thought it did require the Id ;-;

1 Like

I did that but it isn’t solving the main issue.

You can only play Animations you have permissions to use (or simply own the animation).

I am not the owner of the game, also, the creator owns them.

This works for me:

local animator = Instance.new("Animator", script.Parent.Humanoid)
local animation = Instance.new("Animation", animator)

animation.AnimationId = "rbxassetid://9500291276"

local anim = animator:LoadAnimation(animation)
anim.Looped = true
anim:Play()

in starter character scripts
(using a different id)

1 Like

The animation isn’t for a player, it’s for a statue

is the script local or server?

Server script. There isn’t a big difference since the model does nothing but stands there and does the animation on a loop

You can ask the owner for permissions to actually use that animation, or test the script to the game if you haven’t import it.

1 Like
local animationId = "rbxassetid://9495604116"
local Humanoid = script.Parent
local animation = Instance.new("Animation", Humanoid)
animation.AnimationId = animationId 
local Animation = Humanoid:LoadAnimation(animation)

Animation.Looped = true
Animation:Play()

does this work?

ROBLOX doesn’t require you to give permissions if the game is created by the same person. I don’t own the game, the animation creator does.

No. I am starting to think I anchored parts and that’s why. I only have HRP Anchored but everything has collisions off