Elevator part CanCollide fails and movement is jittery with player on part

I want suggestions about how to eliminate or improve the performance of this script.

In Studio, the part and the script work fine. The player and the part move up and down as expected. If I open the game on Roblox on my MacBook, the part is a little jittery, but it does the job. When I run the project on my iPadPro, when the player jumps on the part, it will get very jittery, and most times CanCollide fails, and the player falls through.

The elevator part is anchored, so I can’t use network ownership. I have four elevators, and I converted them all to run off one tagged script; however, it made no difference. I suspect it may be a network performance or processing issue with my devices, but I’m not sure.

Any help or suggestions would be appreciated. Cheers :slight_smile:

local part = script.Parent
local startPosition = part.Position

local amplitude = 11 -- how far the part moves up and down
local frequency = 1 -- how fast the part moves

while true do
	-- Calculate the new Y position based on time
	local newY = startPosition.Y + math.sin(time() * frequency) * amplitude

	-- Update the part position
	part.Position = Vector3.new(startPosition.X, newY, startPosition.Z)

	-- Wait a short time before updating again
	wait(.001)
end

Can you provide any short videos showing your elevator performs? We can understand it more clearly on what it going on. Thanks!

Why don’t you just use a PrismaticConstraint set to Servo. You can change the Position of the Servo so the elevator moves however you want it to. Here’s a sample platform system I made to show someone else how they work: PlatformModel - Roblox
It’s all done with physics, so players don’t lag behind.

Also you should use task.wait(). The minimum for any wait() is about 1/30th of a second, so .03 seconds. You can’t force it to wait shorter than that.

1 Like

Hey, Thanks Scottifly! Took a little playing around, but that works great! Cheers :grinning:

1 Like

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