Animation not playing from script!

The animation value is not nil and it should work and it has no errors, for some reason it does not play!

QAPcore.Animations.Inside.ScrollingFrame.DescendantAdded:Connect(function(object)
	for i,v in pairs(QAPcore.Animations.Inside.ScrollingFrame:GetChildren()) do
		if v.ClassName == "ImageButton" then
			local tmp = QAPcore.Animations.Inside.ScrollingFrame.Template
			v.MouseButton1Click:Connect(function()
				local anim = v.Main.AnimationID
				local preview = QAPcore.Preview.Main.ViewportFrame
				game.Workspace:WaitForChild("Char").Humanoid.Animator:Destroy()
				local newanimator = Instance.new("Animator")
				newanimator.Parent = game.Workspace:WaitForChild("Char").Humanoid
				local animplay = game.Workspace:WaitForChild("Char").Humanoid.Animator:LoadAnimation(anim)
				animplay.Priority = Enum.AnimationPriority.Action
				animplay:Play()
				animplay.Looped = true
			end)
		end
	end
end)

5 Likes

You need to actually create an animation object and set the AnimationId of the animation object to the id. Then you can load the animation object like so:

local a = Instance.new(“Animation”)
a.AnimationId = your_animation_id
hum:LoadAnimation(a):Play()
1 Like

I assume he’s attempting to read the “AnimationId”* (not “AnimationID”) property of Animation. It is best to load the existing Animation instance over creating a copy.

@Spa_rkk, Animator:LoadAnimation requires the whole Animation instance, not just its ID. Correct your code to

local animationTrack = animator:LoadAnimation(button.Animation)
1 Like

Sorry for not specifying that

is an animation object sorry for the confusion

try to change the animator variable to local newanimator = Instance.new("Animator", Char.Humanoid) or Char.Humanoid.Animator
and remove the newanimator.Parent line

1 Like

the new animator works fine its just that it never playes the animations and I can still see that the animator is still there b ecause there are no errors and it detects when a animation is nil

then check your animation id, and make sure the publisher is you, (if this is a team create without a group make sure the publisher is the owner of the game, and if it is in a group then make sure the animation is published under the group)

1 Like

I made the animation five minutes before and published it myself and the game is owned by me

try replacing this line with this
local animplay = newanimator:LoadAnimation(anim)

1 Like

Debug the script by doing print() for example when button pressed, animation played, etc.

1 Like

still does not work
ad
sadsadsadsa

it still does not play the animation but it prints

yeah that means ur animation’s is messed up try publishing a new one

1 Like

Yeah, or maybe it’s the wrong Animation ID or something.

2 Likes

the animation is not messed up I have tried multiple animations

if it prints and the animation doesnt play it means the animation wasn’t accepted by roblox’s moderation

1 Like

Print the animation object

ඞඞඞඞ

1 Like

no animations work, i have tried multiple animations. It seems like its trying to play them because the rig in workspace is unmovable in the animation editor after

I did its just fine
dsadascxscxzcxz

Ok then it’s Roblox problem2!1!1ඞඞ