Why is my animation replicating/being buggy on different clients

Hey, I have a simple emote system I made in which it just plays animations on the client through the client, Sometimes the animation works fine, but for some reason this is the usual result

This is the client that did the emote: https://gyazo.com/6363e8ee59a580aefabf8694e1324ad2 the player waved 1-2 minutes ago

This is the other client: https://gyazo.com/f3088e05433f35509c8959a92671be64 the wave animation just keeps being played on loop, I’m really not sure why this is happening as looped is set to false obviously and the animation is played on the client above, some help would be greatly appreciated

heres the code I didn’t add it because its cluttered and I didn’t think it matters much but here

local function LoadAnimation(AnimationId,looped)

local Character = Player.Character

local Humanoid = Character:WaitForChild("Humanoid")

for i,v in pairs(Humanoid:GetPlayingAnimationTracks()) do
		v:Stop()
end


if animdebounce == false then
	animdebounce = true 

Animator = Humanoid:WaitForChild("Animator")
Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId

AnimationTrack2 = Animator:LoadAnimation(Animation)

AnimationTrack2.Priority = Enum.AnimationPriority.Action

if looped then
	AnimationTrack2.Looped = true
else
	AnimationTrack2.Looped = false
end

	AnimationTrack2:Play()
	
	AnimationTrack2.Stopped:Connect(function()
		AnimationTrack2:Destroy()
	end)

Humanoid.Running:Connect(function(speed)
	if speed >= 0.0001 then
		if AnimationTrack2 then
			AnimationTrack2:Stop()
			AnimationTrack2 = nil
		end		
	end
end)
	
	AnimationTrack2.Stopped:Connect(function()
		animdebounce = false
	end)
   end

end

1 Like

Its really hard to say and could be any number of reasons, without some sort of code to look at, you probably wont get much input on this.

I added the code, just didn’t add it because I didn’t think it was necessary seems theres a ton of replication/animation issues but I guess it is important ur right

It all looks ok, maybe make sure this code isn’t being played several times over.
such as maybe put a print statement near the
AnimationTrack2:Play()
and the
AnimationTrack2.Stopped:Connect

It does appear that tracks are not being destroyed though.
Such as, if you play an animation, then the character ‘runs’ and the track is stopped, it is then
set to nil, so when the AnimationTrack2.Stopped:Connect comes along, its trying to destroy a nil value.

Something just seems off with the logic.

The best you can do is either set .Looped on all clients instead of just the one loading it, or loop it directly in the Animation Editor and get rid of any code changing it manually.

2 Likes

oh my gosh, I am sorry for the late reply THANK you so much, I have been searching for an answer for this forever, thank you! this was the solution, which is so funny because I didn’t even need the looped part of the code it was kinda just there for QOL