The title said it all, animation can’t replicate to server. Recently, i tried to simulate the FPS equipped pose using animation instead of fake arms like many people. I was stuck in this problem that seems not to have an answer yet. I tried everything from loading animation on client to using an animator, it seems that if i load the animation on the server, it still gonna work but there is a problem, i can’t loop the poseanimation in server because runservice seems not to work in server-side and using while loop will cause lag because if you imagine 15-20 players running while loop simultaneously, the server might crash
. The reason i did this is because i can’t pause the animation at a certain position for some reason so another guy in the forum suggested another way, create another animation that loops the last frame of the original animation.
This works but it doesn’t replicate, any suggestion, i would be really appreciate.
Here is the code:
localscript:
repeat
wait()
until game:IsLoaded()
local player = game.Players.LocalPlayer
repeat
wait()
until player.Character.Humanoid.Animator
local animator = player.Character.Humanoid:WaitForChild("Animator")
local contextactionservice = game:GetService("ContextActionService")
local tool
local runservice = game:GetService("RunService")
local function binding(name,inputstate,inputobject)
if name =="pose" and inputstate == Enum.UserInputState.Begin then
local FPS = animator:LoadAnimation(script.Animation)
FPS:Play()
FPS.Stopped:Wait()
tool = runservice.RenderStepped:Connect(function(dt)
local poseanimation = animator:LoadAnimation(script.poseanim)
poseanimation:Play()
end)
elseif name == "reverse"and inputstate == Enum.UserInputState.Begin then
tool:Disconnect()
end
end
contextactionservice:BindAction("pose",binding,true,Enum.KeyCode.E)
contextactionservice:BindAction("reverse",binding,true,Enum.KeyCode.R)
serverscript:
game.Players.PlayerAdded:Connect(function(player)
local char = player.Character
if char then
local animator = Instance.new("Animator")
animator.Parent = char.Humanoid
end
end)
Note: i used animator because it is not safe to use humanoid:LoadAnimation due to the documents in devhub said that it was deprecated.