Player moves choppy inside tweening model

I’m making an elevator game and i need to tween the elevator to a position. I’m tweening it’s primary part. I’ve tried other solutions but none of them help me.
Here’s what’s happening; It isn’t too bad, but it isn’t smooth either.


Here’s my script;

local TS = game:GetService("TweenService")
local dirt = game.Workspace:WaitForChild("Dirt")
local elevator = game.Workspace:WaitForChild("Elevator")
local lights = elevator:WaitForChild("Lights")

local sizeTween = TS:Create(dirt, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In),
	{ Size = Vector3.new(24.202, 151.235, 25.409) }
)

local elevTween = TS:Create(elevator.Primary, TweenInfo.new(5),
	{ CFrame = CFrame.new(-0.123050421, -45.526638, 0.392226428, 1, 0, 0, 0, 1, 0, 0, 0, 1) }
)

local intermission

while true do
	intermission = true
	sizeTween:Play()
	sizeTween.Completed:Wait()
	print("Intermission has ended.")
	intermission = false
	dirt.Size = Vector3.new(24.202, 78.293, 25.409)
	elevTween:Play()
end
2 Likes
1 Like

Is the script a server(/normal) script, or a local script?
If it’s a server script, the choppiness is probably caused by lag between the client and the server. If you want it to be smoother, you should change the part of the code that tweens the elevator to be client sided.

2 Likes

And so how would i move the elevator on the server?

1 Like

You don’t, you make the moving part only on the clients, but the logic (aka when to start moving) on the sevrer

1 Like

What i mean is how would i do the logic on the server if i don’t tween on the server?

1 Like

Every time when the elevator should start moving, you send a remote event (Remote Events and Callbacks | Documentation - Roblox Creator Hub) to all the clients (with myRemote:FireAllClients(blah blah blah)), which tells them to start moving the elevator

1 Like

There would also be a more sophisticated way of doing this, making sure that there would be very minimal delay in when the elevator reaches the bottom for every client and the server, even with a lot of lag, but that’s probably overkill

1 Like

I’m still a little confused. How would the physics still be intact with the server if i tween the model specifically on the client?

Are there unanchored objects moving down with the elevator? If so, then things get a bit more complicated, but I’ll currently assume you’re talking about the players’ physics. Every player would be only affected by their own elevator. Now that would cause the other player’s to look like they’re floating or sinking into the ground a bit, and if that’s also too much of a problem, then you could also move every player’s Y level to be right on the elevator floor for every player, locally of course, however then jumping and climbing etc would get more difficult to maintaim.
The physics would all be done on the clients, so it doesn’t really need to be very intact on the server

2 Likes