Issue with animation scripting

Hello, I am making with friends SCP game but for some reason animations are bit buggy
here is a script:

--anims 
local anims = game.ReplicatedStorage.Animations.S096
local event = game.ReplicatedStorage.scp096event
local rageEvent = false
local InRage = false
local sg 
event.OnServerEvent:Connect(function(plr1,id,plrPos,sgpos)	
	sg = workspace.SCPs:FindFirstChild("SCP096")
	if plr1 == nil then return end
	local hum = sg:WaitForChild("Humanoid")
	local SadIdle = hum:LoadAnimation(anims.IdleSad)
	local SadWalk = hum:LoadAnimation(anims.WalkSad)
	local SadToRage = hum:LoadAnimation(anims.SadToRage)
	local RageRun = hum:LoadAnimation(anims.RageRun)
	local RageIdle = hum:LoadAnimation(anims.RageIdle)
	if id == 1 then

	hum.WalkSpeed = 7

	hum.Running:Connect(function(speed)
		if speed > 0 then
				if not SadWalk.IsPlaying then
					if InRage == false then
						SadIdle:Stop()
						SadWalk:Play()
					else
						SadWalk:Stop()
						SadIdle:Stop()
						RageIdle:Play()
						RageRun:Play()
					end
			end
		else
				if not SadIdle.IsPlaying then
					if InRage == false then
						SadWalk:Stop()
						SadIdle:Play()
					else
						SadWalk:Stop()
						SadIdle:Stop()
						RageRun:Stop()
						RageIdle:Play()
					end
			end
		end
		end)
	elseif id == 2 then
	if not plrPos then warn("Error, Player not found") return end
	if not sgpos then warn("Error, SCP096 not found") return end
		if rageEvent == true then return end
		print("ráge")
	rageEvent = true
	hum.WalkSpeed = 0
	SadIdle:Stop()
	SadWalk:Stop()
	SadToRage:Play()	
		wait(5)
		hum.WalkSpeed = 30
		InRage = true
		
	end
end)

the problem is that for some reason not always it will turn on first idle Animation
and sometimes it takes some time until the script proceed the animation
how to fix it?
video:

This is caused by server lag, and can be fixed by moving your animation system to a localscript.

and everyone still can see the animations?

yes, any animation a local script plays onto a player’s character by the player will replicate to other players.

Oh, I was using server because someone said it can be only seen by local player.

are there any other diffrences between server and local animation playing?

animations played on the server are still good, but not recommended for player characters, as there is a delay between animations playing, localscripts can do this much faster without any delay.

1 Like

Actually, I would reccomend putting all animations on the client, even those of NPCs. I’m pretty sure running NPC animations on the server causes it to replicate every single keyframe, increasing lag.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.