Load Animation not working

Hi guys how are you, im making an emote ui but when i try to play the animation it doesnt work and no error appears.

here is the code:

local Character = LocalPlayer.Character or ( LocalPlayer.CharacterAdded:Wait() and LocalPlayer.Character );
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid;
			
local Animation = Instance.new("Animation");
Animation.AnimationId = "rbxassetid://"..v -- Dance Id;
Animation.Name = k -- Dance Name;
			
local AnimationTrack = Humanoid:LoadAnimation(Animation);
AnimationTrack.Priority = Enum.AnimationPriority.Action
AnimationTrack:Play();

here is the animation

i dont know if its normal but when i put in the workspace it makes a keyframe

3 Likes

Try parenting Animation to Character. Make sure you destroy the animation once the player is finished with it.

1 Like

It doesnt work, but i was looking an when i print the length of the animation it prints 0


local Character = LocalPlayer.Character or ( LocalPlayer.CharacterAdded:Wait() and LocalPlayer.Character );
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid

local Animator = Humanoid:WaitForChild(“Animator”)
			
local Animation = Instance.new("Animation");
Animation.AnimationId = "rbxassetid://"..v -- Dance Id;
Animation.Name = k -- Dance Name;
			
local AnimationTrack =Animator:LoadAnimation(Animation);
AnimationTrack.Priority = Enum.AnimationPriority.Action
AnimationTrack:Play();

Is it in a local or server script? Animations need to be played on the client (local script).

i already tried this script but nothing

I tried plugging your code into a tool-

local players = game:GetService("Players")
local LocalPlayer = players.LocalPlayer

local v = 000000000
local k = "Dance Name"

local Character = LocalPlayer.Character or ( LocalPlayer.CharacterAdded:Wait() and LocalPlayer.Character );
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid;

function activated()
	local Animation = Instance.new("Animation");
	Animation.AnimationId = "rbxassetid://"..v -- Dance Id;
	Animation.Name = k -- Dance Name;

	local AnimationTrack = Humanoid:LoadAnimation(Animation);
	AnimationTrack.Priority = Enum.AnimationPriority.Action
	AnimationTrack:Play();
	print("Play")
end

script.Parent.Activated:Connect(activated)

It works, (at least for me). The problem isn’t this part of the code, it’s whatever you’re doing to call it.

it didnt work for me lol, maybe its my roblox studio error, i dont know…

Did you put it in a tool and change “v” to your animationID?

This is not true. Infact, it might even be worse to use them on a client. Using them on a server is more efficient and will let everybody see what animations you play.

I think either is fine, I’m pretty sure that basic Roblox movement animations are all done on a local script. Players have NetworkOwnership.

Yeah, I think that’s because it was made before the FilteringEnabled updates. They made it work even though it’s on a client and wouldn’t show to other players.

Honestly I don’t know, I’ve had instances where it’s shown for all on client but also not. You’re probably right in that it’s better to fire the server and run it there.

1 Like

Could you maybe send more code or explain how you are calling the function?

for now, im not calling it, i just copy and paste ur code and change the id with mine

Ah, alright. We’ll just put my code in a local script in a tool (make sure to add a handle or turn of RequireHandle in the properties), replace the animationID and it should work.

yeah i know i alr did that but didnt work

Strange, did you encounter any errors in the log?

nope, it didnt, i dont know why it doesnt work

Can you send a screenshot or something (if you don’t mind) so I can see where things are placed?