Why wont the animation play?

  1. What do you want to achieve? A simple drink with an animation

  2. What is the issue? the animation isn’t working

here’s the code:

local Tool = script.Parent
local Anim = Tool.Animation

Tool.Activated:Connect(function()
	local Character = Tool.Parent
	local Humanoid = Character.Humanoid
	
	local AnimationTrack = Humanoid:LoadAnimation(Anim)
	AnimationTrack:Play()
end)

SOME BACKGROUND INFO:

it’s for a cafe game and there’s multiple parts to the coffee, plus there’s a coffee making system so it starts off a regular cup and when you hold it over the sensor (coffee maker) the coffee part’s transparency is set to 0.

2 Likes

I don’t usually deal with animations, what I would recommend though, is that you check for spelling, and capitalization errors.

Check whether or not the character is anchored, welded or another animation is playing over with a higher priority. Also, make sure the Rig is compatible.

First off you need the animation Id. After that then you input it into the code like this:

Tool.Activated:Connect(function()

	local Anim = Instance.new('Animation')

	Anim.AnimationId = 'rbxassetid://--Your Id Goes here'

	PlayAnim = Character.Humanoid:LoadAnimation(Anim)

	PlayAnim:Play()

end

Edit: Put this in a local script inside StarterCharacterScripts Lemme know what happened @hopeshusbvnd I’m curios. Wait a minute this might not work gimme a sec.

2 Likes

There’s already an animation with the AnimationId in the tool but it wont work for some reason

1 Like

Put this in a local script inside the Tool

1 Like

Then send me a screenshot with the code inside the tool.

1 Like

@hopeshusbvnd There is no Id above. Ids are usually 10 digits long.

1 Like

here’s your code inside of the tool.

1 Like

Delete the first 2 Variables @hopeshusbvnd then it should work.

1 Like

Let me know if it works @hopeshusbvnd if it did mark my post as solved.

Here’s a video of what happened after I did that

Gimme a minute to fix this it. It should be done pretty quick.

1 Like

Here for the final time this WILL work:

local Tool = script.Parent
local Animation = --toolname goes here .Animation
Tool.Activated:Connect(function()

local Anim = Instance.new('Animation')
local Character = Tool.Parent
local Humanoid = Character.Humanoid
local AnimationTrack = Humanoid:LoadAnimation(Animation)
Anim.AnimationId = 'rbxassetid://--ID goes here'
AnimationTrack:Play()

end)
Also add a animation inside your tool click the animation the click the animation value then put the animation in their and your done.

i only noticed today that humanoid.LoadAnimation is depreciated
https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation

1 Like

Have you set your animation priority to action? If not, it will not work.