Animation Not Playing

Hi everyone,

I am working on a tool ( a type of drink ) that when activated removes the cap of the bottle and then playes a animation. The Animation doesn’t work and I get this error:

Schermafbeelding 2024-07-03 152256

I am for sure doing something wrong but I can’t find why. Could sombody maybe help me?

The Code:

local AnimationID = 18317418600

script.Parent.Activated:Connect(function(player)
	local Hum = script.Parent.Parent:FindFirstChild("Humanoid")
	script.Parent.Handle.WeldConstraint:Destroy()
	
	local Animation = Instance.new("Animation")
	Animation.AnimationId = AnimationID
	Animation.Name = "Drink_Animation"
	
	local AnimationTrack = Hum:LoadAnimation(Animation)
	AnimationTrack:Play()
end)

(This is in a local script btw)

Try swapping it to:

local AnimationID = "rbxassetid://18317418600"
1 Like

It didn’t work, it did give me a different error this time:

Do you maybe know how to fix this? :sweat_smile:

All humanoids should have something in them called an animator, do this instead:

local AnimationTrack = Hum.Animator:LoadAnimation(Animation)

Is the animation your’s if not it will not work unless you publish it yourself

It did play the animation but it didn’t move the arm, Do you maybe know why this is. I made the Animation with a R15 avatar and my avatar also is R15 so I dont think it has to do with the type of avatar.

This is my result:

make sure the priority on the animation is Action

How can I change that? :smile:

Checked your code and fixed some things, this should work:

local AnimationID = "rbxassetid://18317418600"

script.Parent.Activated:Connect(function(player)
	local Hum = script.Parent.Parent:FindFirstChild("Humanoid")
	local Animator = Hum:FindFirstChildOfClass("Animator")
	script.Parent.Handle.WeldConstraint:Destroy()
	
	local Animation = Instance.new("Animation")
	Animation.AnimationId = AnimationID
	Animation.Name = "Drink_Animation"
	
	local AnimationTrack = Animator:LoadAnimation(Animation)
	AnimationTrack.Priority = Enum.AnimationPriority.Action4 --// Action 4 is the highest
	AnimationTrack:Play()
end)

TYSM it workt!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.