Movement animations not replicating for other clients

After hours of scouring the Devforum, I have not found a single solution to the problem I am facing. My customized “Animate” local script is not replicating for other clients on the server. Obviously this is an issue, because from the POV of other players, you are just gliding around.

What solutions have you tried?
All separate attempts

  1. Creating an Animator instance in the humanoid upon CharacterAdded
  2. Using remotes to communicate between the server & client, when the Animator instance has been replicated on the server, and passing that to the InitAnimations function.
  3. Using remotes to communicate to the server when an animation needs a change.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local Assets = require(ReplicatedStorage.Databases.Assets)
local animationsVar = script.Animations
local player = Players.LocalPlayer
local RemoteHandler = require(player.PlayerScripts.CoreClient.RemoteHandler)
local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local animWeight, targetWeight = {}, {}
local charDancing = false
local initialized

local function SetWeight(anim, weight)
	if not anim or not weight then
		return
	end
	targetWeight[anim] = weight
end
local function InitAnimations()
	if initialized then
		return
	end
	initialized = true
	local anims = {
		WalkForward = hum:LoadAnimation(animationsVar.WalkForward),
		WalkRight = hum:LoadAnimation(animationsVar.WalkRight),
		WalkLeft = hum:LoadAnimation(animationsVar.WalkLeft),
		WalkBack = hum:LoadAnimation(animationsVar.WalkBack),
		Run = hum:LoadAnimation(animationsVar.Run),
		Idle = hum:LoadAnimation(animationsVar.Idle),
		RatDance = hum:LoadAnimation(animationsVar.RatDance)
	}
	for i, v in pairs(anims) do
		v.Priority = Enum.AnimationPriority.Core
		v:Play(0, 0.01, 0)
		v:AdjustWeight(0)
		do
			animWeight[v] = 0
			targetWeight[v] = 0
		end
	end
	RunService.RenderStepped:Connect(function()
		local dir = root.CFrame:VectorToObjectSpace(root.AssemblyLinearVelocity)
		local moveSpeed = dir.Magnitude
		local isRunning = hum.WalkSpeed >= 20
		if charDancing and moveSpeed > 0.5 then
			charDancing = false
			anims.RatDance:Stop()
		end
		for i, v in pairs(anims) do
			SetWeight(v, 0)
		end
		do
			if moveSpeed < 0.5 then
				SetWeight(anims.Idle, 1)
				anims.Idle:AdjustSpeed(1)
			elseif isRunning and dir.Z < -1 then
				SetWeight(anims.Run, 1)
				anims.Run:AdjustSpeed(1.5)
			else
				if dir.Z < -1 then
					SetWeight(anims.WalkForward, 1)
					anims.WalkForward:AdjustSpeed(1)
				elseif dir.Z > 1 then
					SetWeight(anims.WalkBack, 1)
					anims.WalkBack:AdjustSpeed(1)
				end
				if dir.X > 1 then
					SetWeight(anims.WalkRight, 1)
					anims.WalkRight:AdjustSpeed(1)
				elseif dir.X < -1 then
					SetWeight(anims.WalkLeft, 1)
					anims.WalkLeft:AdjustSpeed(1)
				end
			end
		end
		for i, v in pairs(targetWeight) do
			local current = animWeight[i] or 0
			local newWeight = current + (v - current) * 0.2
			i:AdjustWeight(newWeight)
			animWeight[i] = newWeight
		end
	end)
	TextChatService.SendingMessage:Connect(function(msg)
		if string.lower(msg.Text) == "lemme show you how we really do it" and not charDancing then
			anims.RatDance:Play(0, 0.01, 0)
			charDancing = true
		end
	end)
end
InitAnimations()

Folder Setup:
image

Any help towards getting this in a working state would be greatly appreciated.

Could you try and play the animations in the moveSpeed < 0.5 e.t.c this way we can verify it’s working for everyone? Clients should be able to control their own animations and replicate it to the server so I don’t see why this isn’t working. I assume animation overlapping if anything.

I don’t see how this could help, considering all animations play perfect and as intended on the clients own view. Correct me if I’m wrong, but if the animations were overlapping, we’d certainly see something?

Exactly, but it’s just weird regardless and doesn’t hurt to try. Clients Control their animation only on their humanoid and replicates it to the server.

I don’t know i may not be much use here since i never made my own animation local script, you could try cloning the Roblox’s Animate script then adjust it to your needs :person_shrugging:

Are you destroying and recreating the Animator locally, on the client? If so, that breaks replication to other clients AFAIK.

I do not handle the Animator instance at all.

I’ll give this a shot and update about it later, its worth a shot

Hm. Perhaps this helps:

1 Like

After a further test by Loading the animations directly onto the animator, this did not make a difference whatsoever.