Issues with playing animations on the server

I’m having an issue stopping/playing animations on the server. It just looks very laggy sometimes

Here’s a video of the issue:
[Watch 2024-03-03 21-32-09 | Streamable]

Here’s the current script for playing the animations: (it’s messy, I know)

local function OpenDoor()
	leverAnimations.Up:Play()
	leverAnimations.Down:Stop()
	leverAnimations.DownIdle:Stop()
	leverAnimations.Up.Stopped:Wait()
	leverAnimations.UpIdle:Play()
	
	doorAnimations.Open:Play()
	doorAnimations.Close:Stop()
	doorAnimations.CloseIdle:Stop()
	doorAnimations.Open.Stopped:Wait()
	doorAnimations.OpenIdle:Play()
	
	DoorChanging = false
end

local function CloseDoor()
	leverAnimations.Down:Play()
	leverAnimations.Up:Stop()
	leverAnimations.UpIdle:Stop()
	leverAnimations.Down.Stopped:Wait()
	leverAnimations.DownIdle:Play()
	
	doorAnimations.Close:Play()
	doorAnimations.Open:Stop()
	doorAnimations.OpenIdle:Stop()
	doorAnimations.Close.Stopped:Wait()
	Shake:FireAllClients("Explosion")
	doorAnimations.CloseIdle:Play()
	
	DoorChanging = false
end
  1. Why are you running it on the server (You should run it on the client)
  2. Is the animation being loaded onto the Humanoid?

I don’t know how to make the video an embed, but it plays the animation and everything is loaded, but it just looks glitchy. It’s on the server because I need it to be visible to all players (not a humanoid) it’s a door with an animation controller

last time I checked, animations replicated from the client.

It’s not being handled by a client, it’s a door that anyone can interact with

Yes, but you can tell the client to hire an animation when fired.

The client does not own it therefore I don’t want to play it on the client

Please read up on stuff before telling people what to do

The sliding door animation looks smooth in the video?

Do you mean the brief glitch that’s visible with the door?

I assume you have the animations preloaded?

Yes, I load the animations when the game starts, then I play them

I think the glitch has something to do with the pause between stopping and playing the animations

What if you try

task.wait(leverAnimations.Down.Length)

Instead of the Stopped event.

It’s not that part that’s bugging, it’s whenever I start the animation. Currently it starts the close/open animation for the door, then stops the opposite anima

Oh sorry I meant

task.wait(leverAnimations.Down.Length - 0.1)

So it calls play on the other one a bit sooner.

I’m not sure what you mean though.

I figured out how to fix this. The animations weren’t loaded yet on the client, so when an animation played there was a delay for loading. I just added it to ReplicatedStorage so my loading screen included them.

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