Animations not replicating

Movement animations within my game aren’t replicating to other clients, and its only the walk animations for some odd reason, as seen here


Everything I have tried:

  • Creating the animator object via server
  • Changing animation weights to 0.01 instead of 0 when stopping an animation
  • Changing animation priority to action

I’ve had this issue across multiple of my games that feature custom movement animations, any help would be appreciated.


local Engine = path.to.Engine

local References = Engine.References
local Maid = Engine:load("Maid").new()

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

local Main = ReplicatedStorage:WaitForChild("game", 100)
local Folder = Main:WaitForChild("animations", 100)

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid", 100)
local RootPart = Character:WaitForChild("HumanoidRootPart", 100)
local Animator = Humanoid:WaitForChild("Animator", 100)

local Mechanics = References.PlayerScripts:WaitForChild("mechanics", 100)
local ClientEngine = References.PlayerScripts:WaitForChild("ClientEngine", 100)
local GetUpController = Mechanics:WaitForChild("getUp", 100)

local Animations = {
        Front = Animator:LoadAnimation(Folder.Player.Walk.Front),
        Back = Animator:LoadAnimation(Folder.Player.Walk.Back),

        Right = Animator:LoadAnimation(Folder.Player.Walk.Right),
        Left = Animator:LoadAnimation(Folder.Player.Walk.Left),

        FrontRight = Animator:LoadAnimation(Folder.Player.Walk.FrontRight),
        FrontLeft = Animator:LoadAnimation(Folder.Player.Walk.FrontLeft),
        BackRight = Animator:LoadAnimation(Folder.Player.Walk.BackRight),
        BackLeft = Animator:LoadAnimation(Folder.Player.Walk.BackLeft),

        Idle = Animator:LoadAnimation(Folder.Player.Idle),
        Fall = Animator:LoadAnimation(Folder.Player.Fall),

        JumpLow = Animator:LoadAnimation(Folder.Player.Jump.Low),
        JumpHigh = Animator:LoadAnimation(Folder.Player.Jump.High),
        JumpSprint = Animator:LoadAnimation(Folder.Player.Jump.Sprint),
}
local States = {
        Current = Animations.Idle,
        Jumping = false
}

for Index, Value in next, Animations do
        if Value and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" then
                Value.Priority = Enum.AnimationPriority.Action
        else
                Value.Priority = Enum.AnimationPriority.Action2
                Value:AdjustWeight(2, 0.1)
        end
end

function ToWalkRelativeToHRP(Humanoid, Direction, RootCompare)
        if Direction ~= nil then
                local RootFacing = RootCompare.CFrame.LookVector
                local RootRight = RootCompare.CFrame.RightVector

                local DirectionRelativeToRootFront = RootFacing:Dot(Direction, RootFacing)
                local DirectionRelativeToRootSides = RootRight:Dot(Direction, RootRight)

                local Output = nil

                if DirectionRelativeToRootFront <= 1 and DirectionRelativeToRootFront >= 0.75 then
                        Output = "Front"
                elseif DirectionRelativeToRootFront >= -1 and DirectionRelativeToRootFront <= -0.75 then
                        Output = "Back"
                elseif DirectionRelativeToRootSides <= 1 and DirectionRelativeToRootSides >= 0.75 then
                        Output = "Right"
                elseif DirectionRelativeToRootSides >= -1 and DirectionRelativeToRootSides <= -0.75 then
                        Output = "Left"
                elseif DirectionRelativeToRootFront <= 1 and DirectionRelativeToRootFront >= 0.5 and DirectionRelativeToRootSides <= 1 and DirectionRelativeToRootSides >= 0.5 then
                        Output = "FrontRight"
                elseif DirectionRelativeToRootFront <= 1 and DirectionRelativeToRootFront >= 0.5 and DirectionRelativeToRootSides >= -1 and DirectionRelativeToRootSides <= -0.5 then
                        Output = "FrontLeft"
                elseif DirectionRelativeToRootFront >= -1 and DirectionRelativeToRootFront <= -0.5 and DirectionRelativeToRootSides <= 1 and DirectionRelativeToRootSides >= 0.5 then
                        Output = "BackRight"
                elseif DirectionRelativeToRootFront >= -1 and DirectionRelativeToRootFront <= -0.5 and DirectionRelativeToRootSides >= -1 and DirectionRelativeToRootSides <= -0.5 then
                        Output = "BackLeft"
                end

                return Output
        end
end

Maid["HumanoidChanged"] = Humanoid.Changed:Connect(function(State)
        if State == "Jump" and States.Jumping then
                Humanoid.Jump = false
        end
end)

Maid["StateChanged"] = Humanoid.StateChanged:Connect(function(Old, New)
        if New == Enum.HumanoidStateType.Jumping then
                if not States.Jumping then
                        if References.PlayerScripts.controllers.movementController:GetAttribute("sprinting") then
                                Animations.JumpSprint:Play(0.2)
                                
                                task.wait(0.1)
                                States.Jumping = true

                                task.delay(Animations.JumpSprint.Length >= 0.1 and Animations.JumpSprint.Length - 0.2 or 0.3, function()
                                        Animations.JumpSprint:Stop(0.2)
                                        task.wait(1)
                                        States.Jumping = false
                                end)
                        else
                                Animations.JumpLow:Play(0.2)
                                
                                task.wait(0.1)
                                States.Jumping = true
                                
                                task.delay(Animations.JumpLow.Length >= 0.1 and Animations.JumpLow.Length - 1 or 0.2, function()
                                        Animations.JumpLow:Stop(0.4)
                                        task.wait(1)
                                        States.Jumping = false
                                end)
                        end
                end
        elseif New == Enum.HumanoidStateType.Seated then
                script:SetAttribute("PerformingAction", true)

                for Index, Value in next, Animations do
                        if Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        elseif New ~= Enum.HumanoidStateType.Seated then
                script:SetAttribute("PerformingAction", false)
        end
end)

Maid["AttributeChangedSignal"] = script:GetAttributeChangedSignal("WalkDirection"):Connect(function()
        if script:GetAttribute("WalkDirection") == "Front" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.Front:Play(0.25)
                Animations.Front:AdjustWeight(1, 0.25)
                Animations.Front.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.Front

                for Index, Value in next, Animations do
                        if Index ~= "Front" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "Idle" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.Idle:Play(0.25)
                Animations.Idle:AdjustWeight(1, 0.25)
                Animations.Idle.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.Idle

                for Index, Value in next, Animations do
                        if Index ~= "Idle" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "Back" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.Back:Play(0.25)
                Animations.Back:AdjustWeight(1, 0.25)
                Animations.Back.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.Back

                for Index, Value in next, Animations do
                        if Index ~= "Back" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "Left" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.Left:Play(0.25)
                Animations.Left:Play(0.25)
                Animations.Left.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.Left

                for Index, Value in next, Animations do
                        if Index ~= "Left" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "Right" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.Right:Play(0.25)
                Animations.Right:AdjustWeight(1, 0.25)
                Animations.Right.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.Right

                for Index, Value in next, Animations do
                        if Index ~= "Right" and Index ~= "Jump" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "FrontRight" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.FrontRight:Play(0.25)
                Animations.FrontRight:AdjustWeight(1, 0.25)
                Animations.FrontRight.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.FrontRight

                for Index, Value in next, Animations do
                        if Index ~= "FrontRight" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "FrontLeft" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.FrontLeft:Play(0.25)
                Animations.FrontLeft:AdjustWeight(1, 0.25)
                Animations.FrontLeft.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.FrontLeft

                for Index, Value in next, Animations do
                        if Index ~= "FrontLeft" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirection") == "BackRight" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.BackRight:Play(0.25)
                Animations.BackRight:AdjustWeight(1, 0.25)
                Animations.BackRight.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.BackRight

                for Index, Value in next, Animations do
                        if Index ~= "BackRight" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
        if script:GetAttribute("WalkDirecton") == "BackLeft" and not script:GetAttribute("PerformingAction") and not GetUpController:GetAttribute("toggle") and not ClientEngine:GetAttribute("Ragdoll") then
                Animations.BackLeft:Play(0.25)
                Animations.BackLeft:AdjustWeight(1, 0.25)
                Animations.BackLeft.TimePosition = script:GetAttribute("TimePosition")
                States.Current = Animations.BackLeft

                for Index, Value in next, Animations do
                        if Index ~= "BackLeft" and Index ~= "JumpLow" and Index ~= "JumpHigh" and Index ~= "JumpSprint" and Index ~= "Fall" then
                                Value:AdjustWeight(0.01, 0.25)
                        end
                end
        end
end)

Maid["RenderStepped"] = RunService.RenderStepped:Connect(function()
        local ForceVector = ToWalkRelativeToHRP(Humanoid, Humanoid.MoveDirection, RootPart)
        script:SetAttribute("TimePosition", States.Current.TimePosition)

        if ForceVector == "Front" then
                script:SetAttribute("WalkDirection", "Front")
        elseif ForceVector == "Back" then
                script:SetAttribute("WalkDirection", "Back")
        elseif ForceVector == "Right" then
                script:SetAttribute("WalkDirection", "Right")
        elseif ForceVector == "Left" then
                script:SetAttribute("WalkDirection", "Left")
        elseif ForceVector == nil then
                script:SetAttribute("WalkDirection", "Idle")
        elseif ForceVector == "FrontLeft" then
                script:SetAttribute("WalkDirection", "FrontLeft")
        elseif ForceVector == "FrontRight" then
                script:SetAttribute("WalkDirection",  "FrontRight")
        elseif ForceVector == "BackLeft" then
                script:SetAttribute("WalkDirection", "BackLeft")
        elseif ForceVector == "BackRight" then
                script:SetAttribute("WalkDirection", "BackRight")
        end

        if (RootPart.AssemblyLinearVelocity * Vector3.new(1, 0, 1)).Magnitude <= 2 and not UserInputService:IsKeyDown(Enum.KeyCode.W) and not UserInputService:IsKeyDown(Enum.KeyCode.A) and not UserInputService:IsKeyDown(Enum.KeyCode.S) and not UserInputService:IsKeyDown(Enum.KeyCode.D) then
                Animations.Front:Stop(0.2)
                Animations.Back:Stop(0.2)
                Animations.Right:Stop(0.2)
                Animations.Left:Stop(0.2)
                Animations.FrontRight:Stop(0.2)
                Animations.FrontLeft:Stop(0.2)
                Animations.BackRight:Stop(0.2)
                Animations.BackLeft:Stop(0.2)
                
                Animations.Front:AdjustWeight(0.01, 0.2)
                Animations.Back:AdjustWeight(0.01, 0.2)
                Animations.Right:AdjustWeight(0.01, 0.2)
                Animations.Left:AdjustWeight(0.01, 0.2)
                Animations.FrontRight:AdjustWeight(0.01, 0.2)
                Animations.FrontLeft:AdjustWeight(0.01, 0.2)
                Animations.BackRight:AdjustWeight(0.01, 0.2)
                Animations.BackLeft:AdjustWeight(0.01, 0.2)
        end
end)

Maid["Destroying"] = script.Destroying:Connect(function()
        Maid:DoCleaning()
end)
1 Like