Replicate Animation to all clients

Mouse.Button1Down:Connect(function()
			if plr.Character then
				local Peck = plr.Character:FindFirstChild("Peck")
				if Peck then
					local humanoid = plr.Character:FindFirstChild("Humanoid")
					if humanoid then
						local PeckTrack = humanoid:LoadAnimation(Peck)
						PeckTrack.Looped = false
						PeckTrack:Play()
						print("Lol")
					end
				end
			end
		end)
``` I heard somewhere that playing animations in client replicates to all clients but isn't happening for me?
1 Like

Play the animation on the server instead. Send a remote event to play it when the player presses the button. Or as @jakebball11 said, it might be an ownership issue.

1 Like

Any animations are automatically replicated. This is most likely an issue with the network ownership of your custom character model.

2 Likes

Does the “Peck” object exist? It could seem like it is stopping the animation from playing

Would I have to load the animation each time the remote event is fired?

No, if all goes right you don’t even have to sync it to the server. First check if there’s an issue with network ownership of the character.

If however you choose to do it on the server, you can store the animations in a table and create them once, then just reference them by name/ID. You could just create a new object each time, but it’s not the most efficient way to do it.

I am not able to find the issue for network ownership, can you give a few hints?

If you didn’t purposely set the network ownership of the character then see if other scripts do it. Look for things like “SetNetworkOwner”.

Still not working


local function LoadAnimations(plr)
	if plr.Character then
		local Animation = Instance.new("Animation", plr.Character)
		local Humanoid = plr.Character:FindFirstChild("Humanoid")
		if Humanoid then
			Animation.Name = "Peck"
			Animation.AnimationId = "rbxassetid://6021681847"
		end
	end
end
local function LoadChicken(plr)
	local ChickenClone = ServerStorage:WaitForChild("Chickens"):WaitForChild("Default Chicken"):Clone()
	ChickenClone.Name = plr.Name
	local _1 = plr.Character
	if _1 ~= nil then
		_1:Destroy()
	end
	plr.Character = ChickenClone
	
	ChickenClone.Parent = Workspace
	
	local Animate = plr.Character:WaitForChild("Animate")
	Animate.Disabled = false
	LoadAnimations(plr)
end
 -- Server
Mouse.Button1Down:Connect(function()
			if plr.Character then
				local Peck = plr.Character:FindFirstChild("Peck")
				if Peck then
					local humanoid = plr.Character:FindFirstChild("Humanoid")
					if humanoid then
						local PeckTrack = humanoid:LoadAnimation(Peck)
						PeckTrack.Looped = false
						PeckTrack:Play()
						print("Lol")
					end
				end
			end
		end)

--Client

Humanoid:LoadAnimation was deprecated for this reason. There were issues with replication and not loading the correct animators, etc. Instead, try referencing the correct animator and then use load animation on the animator itself. The Animator can be found as a child of the Humanoid. Just reference it by:

local animator = humanoid:WaitForChild("Animator")
local PeckTrack = animator:LoadAnimation(Peck)

This may or may not fix the issues you were having. I believe the main issue was referencing the incorrect animator, which doesn’t seem to be the case here, but it is still worth a shot.

I’d suggest trying this with your original and seeing if it replicates, not the version with the remote event.

I found the problem, the custom character model needs a Animator.