Animation is only playing on the server side?

Hello, I want to create a swimming system. This has already been completed.

However there is a problem when it comes to animating the player when he swims.
Whatever I did, the animation couldn’t play, the game is only for R6 characters, the animation is made for R6 Characters. I tried playing it on the client, on a server. And the closest I got was making the animation play only on the server side.
The animation is only played on the server side. Which means.
You can only see other players playing the “Swim animation” but you can’t see yourself swimming.

I made a testing place dedicated to playing this animation to see if Roblox was broken or something.
Here’s the server sided script i’m using to play the animation

local Players = game.Players

Players.PlayerAdded:Connect(function(Plr)
	local Character = Plr.Character or Plr.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid")
	local Animator = Humanoid:WaitForChild("Animator")
	
	local Animation = script.SwimAnim
	local AnimTrack : AnimationTrack = Animator:LoadAnimation(Animation)
	AnimTrack.Priority = Enum.AnimationPriority.Action4
	AnimTrack.Looped = true
	AnimTrack:Play()
	
	print("Debug.")
	
end)

The animation only plays on the server side, and not on the client side.
When I play the animation on the client side, it doesn’t play at all.

Please help. I’ve been losing my mind to this.

Does the client get any asset errors in the output?

Something that may help you understand what’s going on is to try debugging via printing all of the animations currently playing in the character on a client script. You could also try checking to see if the animation you’ve loaded to play on the character through the server is playing specifically.

local animator: Animator = -- ... put your humanoid.Animator here
local animationToCheck: Animation = -- ... put the reference to your Animation here

for _,track: AnimationTrack in animator:GetPlayingAnimationTracks() do
	if track.Animation == animationToCheck then
		print(`{animationToCheck.Name} is playing on the client.`)
	end
end

.PlayerAdded doesn’t always assure triggering for the first player joining the game, or especially on the client.

For this to work you have to loop thru the players already existing in game, as well as connecting .PlayerAdded

local Players = game.Players

local function onPlayerAdded(Plr)
	local Character = Plr.Character or Plr.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid")
	local Animator = Humanoid:WaitForChild("Animator")
	
	local Animation = script.SwimAnim
	local AnimTrack : AnimationTrack = Animator:LoadAnimation(Animation)
	AnimTrack.Priority = Enum.AnimationPriority.Action4
	AnimTrack.Looped = true
	AnimTrack:Play()
	
	print("Debug.")
	
end

Players.PlayerAdded:Connect(onPlayerAdded)

for _, Plr: Player in Players:GetPlayers() do
    task.spawn(onPlayerAdded, Plr)
end

Nope, there’s not a single error in the output.
Also thanks for the code snippet for animations, it doesn’t print out anything though.
I added a else statement incase just to be sure.
And still nothing on the client side.

Thanks for the info about .PlayerAdded ! I didn’t know .PlayerAdded was unreliable.
Though, the .PlayerAdded is only here to test if the animation is playing on the client / server side.
It’s a debug script of sorts.

I’ve also noticed that you are setting .Looped = true via script. There’s a very old issue of Looped property not replicating to the Server/Client when set via script. I’d suggest you setting the animation to looped via animation editor and reuploading it.

The animation has already been set to looped in the animation editor
I was making sure the animation was really looping by making it looped in the script.

If you called :play() on the client but no animation is playing, and nothing prints when you use getplayinganimationtracks(), then the animation is being stopped by another script or not loaded correctly.

If you don’t see output errors, then use the find all replace all tab to search “stop()” and check if another script is intervening.

If this is the server sided script then where is the client sided script?