Animation not working [unsolved]

Hello everyone,

For me its my first time using animation in scripts and I am having some issues with playing the script. The script is client-sided and gives no error code.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local remote = ReplicatedStorage.Events.Remote:FindFirstChild("RemoteEvent")
local Players = game:GetService("Players") 
local Debounce = true
local Animation = ReplicatedStorage.Assets.Animations.TestAnimEvent
local Humanoid = Players.LocalPlayer.Character:FindFirstChild("Humanoid")

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent, mouse)
	if gameProcessedEvent then return end
	if Debounce == false then return end
	if input.KeyCode == Enum.KeyCode.E then
		Debounce = false
			
		local AnimationTrack = Humanoid:LoadAnimation(Animation)
		
		AnimationTrack:Play()
			
		local mouse = Players.LocalPlayer:GetMouse()
	
			remote:FireServer(mouse.Hit)
			wait(1)
		Debounce = true
	end
end)

Can anyone help me the cause of this problem?

Thanks!

2 Likes

Hey, try replacing Humanoid with Humanoid.Animator.

If this simple tip fails- I will put research into this, and I will come back once I find a solution.

1 Like

It still does not work, does it have to do with the animation itself?

1 Like

Maybe, try opening your Animation in the Animation Editor, then click the three dots, and go to Set Animation Priority. Tell me what it is checked at.

It is set on action. how can that matter?

Alright, usually if its set lower, it won’t display properly.

Alright- to collect more information, how does this work?

  1. Where is the script location?
  2. It’s client sided, yes? Make sure its in either StarterPlayerScripts or StarterCharacterScripts.
  3. Add some print statements at the start of the function- then before and after the if input.KeyCode statement. Does it print out all functions?

Since there are no errors, it makes this slightly trickier. I would appreciate it if you answered all these questions within one post.

1 Like

1&2. its in StarterPlayerScripts
3 I don’t think that would work because if that is so how can the remote event after that be fired if there’s an error

Well, I was never told that the RemoteEvent fired or not. However, I’d recommend-

  1. Make an IntValue- place it under the script. Name it “AnimationID”
  2. Set the value of IntValue to the same AnimationId of the “TestAnimEvent”.
  3. Now, Inside the Script, replace the Animation variable with this.
local Animation = Instance.new("Animation")
Animation.Parent = script
Animation.Name = "TestAnimEvent"
Animation.AnimationId = script.AnimationID.Value

Tell me if this works.

it is still not working but thank you for your input.

If the animation loads but nothing plays and there are no errors, the most common cause is that the animation is not being loaded through the Animator object or the animation asset is not owned by the correct creator.

Make sure your character actually has an Animator inside the Humanoid, and always load animations from there. Also confirm that the AnimationId is in this format:

rbxassetid://1234567890

Here is a simple working pattern:

local humanoid = character:WaitForChild(“Humanoid”)
local animator = humanoid:WaitForChild(“Animator”)

local track = animator:LoadAnimation(animation)
track:Play()

Another thing to check is ownership. If the animation was created under your personal account but the game belongs to a group, the animation will not play unless it is published under that same group.

Typical checklist:

AnimationId uses rbxassetid:// format
Animation is owned by the same user or group as the game
Animator exists inside the Humanoid
Animation priority is set high enough, usually Action

I made a short step by step tutorial that shows the full workflow from creating the animation to publishing and playing it in a script, including the ownership and priority parts:

As @TheKozzz suggested, make sure that your animaton is uploaded under the game’s creator.
(If your animation is owned by a group, set the animation’s Creator to that group. Otherwise, only the creator will be able to see it, but it should typically throw an error.)
Check if your Animation Object has the correct animation ID. If it does, try re-uploading the animation or set its Priority to Action4.


Not true. There are cases when the AnimationPriority needs to be Walk, Idle etc. It really depends on your use case.

Let’s say you have a sword animation. When you click, you want it to play a swing animation. Let’s say you are walking and you want to attack someone. Because your AnimationPriority is set to Idle, the walking animation “overrides” all the moving parts (moving parts as in all the parts that you moved within the animation). If you have a walking animation that for some reason does NOT move the left hand, your animation will animate the left hand because it is not overridden by anything.
AnimationPriority Documentation

Action4 has the highest priority, followed by Action3, Action2 and Action.

Buddy this is more than 2 years old can you not bump ancient posts
(also i’d like to say it is true lmao, most people play custom animations and they will blend with eachother if not prioritized properly)

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local UserInputService = game:GetService(“UserInputService”)
local Players = game:GetService(“Players”)

local remote = ReplicatedStorage.Events.Remote:WaitForChild(“RemoteEvent”)
local Animation = ReplicatedStorage.Assets.Animations:WaitForChild(“TestAnimEvent”)

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild(“Humanoid”)
local Animator = Humanoid:WaitForChild(“Animator”)

local Debounce = true

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if not Debounce then return end
if input.KeyCode == Enum.KeyCode.E then
Debounce = false

	local AnimationTrack = Animator:LoadAnimation(Animation)
	AnimationTrack:Play()

	local mouse = player:GetMouse()
	remote:FireServer(mouse.Hit)

	task.wait(1)
	Debounce = true
end

end)

Try this tell me if it works or not