Not being able to get Client Animation on server

I’m playing an animation on the client, then I fire a remote event to the server and try to get that Animation by looping through the humanoid’s playing animation tracks. But for some reason the client animation isn’t in the table. I’ve also tried switching to server right after playing the animation to see if it was getting replicated and it was.

for _, AnimationTrack in pairs(Humanoid:GetPlayingAnimationTracks()) do
			
	print(AnimationTrack.Animation.AnimationId)
			
end

This is the code I used on the server to try to get the animation, and I printed the ID of all the animations and none of them were the Client Animation. So does anyone know how I would get that animation?

Are you firing the remote immediately after running the animation from the client? It may be that RemoteEvent is arriving at the server before the replication of the animation. I was having the same results as you when testing, but throwing in a task.wait() right before having the server check for the animation did end up with the client animation in the list.

That being said, I can’t say confidently that this method would be reliable in a live server. Perhaps you could mitigate latency issues by having the server check multiple times until it finds the animation or until a timeout occurs to prevent infinite looping.

Tried to constantly check for playing animations in server in a while loop, and it never has the client animation, weird…

Perhaps our set-ups are different? Here’s what I have:

I have a RemoteEvent in ReplicatedStorage named “Check.”

Client code, in StarterPlayerScripts:

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://6654867550" --You'll need to change this to your animation.

local humanoid do
	local player = game:GetService("Players").LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait()
	humanoid = character:WaitForChild("Humanoid")
end
local animator = humanoid:WaitForChild("Animator")
local track = animator:LoadAnimation(animation)

task.wait(2) --Added the wait here just so I could see the animation run.
track:Play()

game.ReplicatedStorage.Check:FireServer()

for _,running_track in ipairs(humanoid:GetPlayingAnimationTracks()) do
	print(running_track.Animation.AnimationId)
end

Server code:

game.ReplicatedStorage.Check.OnServerEvent:Connect(function(player)
	task.wait()
	if not (player.Character and player.Character:FindFirstChild("Humanoid")) then return end
	for _,running_track in ipairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
		print(running_track.Animation.AnimationId)
	end
end)

This code detects both my player’s idle animation and the animation I loaded in from both the client and the server ends.