Elevator making player bounce/shake everywhere as it's moving

Hello,

So I have an elevator from a YouTube tutorial that works with TweenService. After taking it, I revamped the model quite a bit to my liking including making the distance from the elevator to its destination a bit longer than from how the tutorial had it set. For some reason though, the player starts to shake/bounce around as the elevator moves and occasionally even end up clipping outside of the elevator as it’s moving. The speed isn’t too fast either and so I can’t see how that would be the issue. I’m pretty confused onto why these problems are happening. I’ve looked at past threads from people with a similar problem and the people who kept helping them simply referred them to a reply made by the developer of The Wild West on another thread. This didn’t really help me too much though to say the least.

Here’s a few clips of MY problem:

Being in the elevator normally

When you decide to back up towards the corners as the elevator moves (no I’m not jumping)

As you see, it’s a pretty annoying thing to experience.

There’s how the model is set up:

image
image

The code inside the script (nothing too crazily complex):

local elevator = script.Parent

local cabin = elevator:WaitForChild("Cabin"):WaitForChild("Cabin")
local cabinBtns = cabin.Parent:WaitForChild("Buttons")

local callBtns = elevator:WaitForChild("CallButtons")

local doors = elevator:WaitForChild("Doors")


local elevatorQueue = {}
local currentFloor = 1


local elevatorSpeed = 17
local doorSpeed = 4

local tweenService = game:GetService("TweenService")
local doorTI = TweenInfo.new(doorSpeed, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)


local elevatorMoving = false


for i, cabinPart in pairs(cabin.Parent:GetDescendants()) do
	
	if cabinPart:IsA("BasePart") and cabinPart ~= cabin then
		
		local weldConstraint = Instance.new("WeldConstraint")
		weldConstraint.Part0 = cabinPart
		weldConstraint.Part1 = cabin
		weldConstraint.Parent = cabinPart
		
		cabinPart.Anchored = false
	end
end


local CallButtonClickDetector = callBtns.CallButton1.ClickDetector
local DownButtonClickDetector = cabinBtns.DownButton.ClickDetector


for i, btn in pairs(cabinBtns:GetChildren()) do
	
	DownButtonClickDetector.MouseClick:Connect(function()
		table.insert(elevatorQueue, btn.Name)
	end)
end
for i, btn in pairs(callBtns:GetChildren()) do

	CallButtonClickDetector.MouseClick:Connect(function()
		table.insert(elevatorQueue, btn.Name)
	end)
end


while true do
	
	local instruction
	
	repeat 
		wait()
		instruction = elevatorQueue[1]
	until instruction

	

		

	if instruction == "CallButton1" or instruction == "Floor1Button" then
		CallButtonClickDetector:Destroy()
		task.wait(2)
		local LeftDoorOpeningSound = script.Parent.Doors.Floor1.LeftDoor.LeftDoor.ElevatorOpening
		local RightDoorOpeningSound = script.Parent.Doors.Floor1.RightDoor.RightDoor.ElevatorOpening
		local lDoor = doors["Floor1"].LeftDoor
		tweenService:Create(lDoor.LeftDoor, doorTI, {Size = lDoor.LeftDoorOpened.Size, CFrame = lDoor.LeftDoorOpened.CFrame}):Play()
		local rDoor = doors["Floor1"].RightDoor
		tweenService:Create(rDoor.RightDoor, doorTI, {Size = rDoor.RightDoorOpened.Size, CFrame = rDoor.RightDoorOpened.CFrame}):Play()
		task.wait(0.5)
		LeftDoorOpeningSound:Play()
		RightDoorOpeningSound:Play()
		elevatorMoving = false
		wait(doorSpeed)
		currentFloor = 1
		table.remove(elevatorQueue, 1)
		elevatorMoving = true
		
		
		if currentFloor ~= 1 then
			local lDoor = doors["Floor" .. currentFloor].LeftDoor
			tweenService:Create(lDoor.LeftDoor, doorTI, {Size = lDoor.LeftDoorClosed.Size, CFrame = lDoor.LeftDoorClosed.CFrame}):Play()
			local rDoor = doors["Floor" .. currentFloor].RightDoor
			tweenService:Create(rDoor.RightDoor, doorTI, {Size = rDoor.RightDoorClosed.Size, CFrame = rDoor.RightDoorClosed.CFrame}):Play()
			wait(doorSpeed)
			local ElevatorCeiling = game.Workspace.ElevatorCeiling
			ElevatorCeiling.ElevatorSound:Play()
			
			local elevatorTI = TweenInfo.new(elevatorSpeed * math.abs(currentFloor - 1), Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
			tweenService:Create(cabin, elevatorTI, {CFrame = cabin.CFrame + Vector3.new(0, (doors["Floor1"].RightDoor.RightDoor.Position.Y - cabin.Position.Y), 0)}):Play()
			
			
			wait(elevatorSpeed * math.abs(currentFloor - 1))
		end
	
	elseif instruction == "CallButton2" or instruction == "DownButton" then

		elevatorMoving = true


		if currentFloor ~= 2 then
			DownButtonClickDetector:Destroy()

			local lDoor = doors["Floor" .. currentFloor].LeftDoor
			tweenService:Create(lDoor.LeftDoor, doorTI, {Size = lDoor.LeftDoorClosed.Size, CFrame = lDoor.LeftDoorClosed.CFrame}):Play()
			local rDoor = doors["Floor" .. currentFloor].RightDoor
			tweenService:Create(rDoor.RightDoor, doorTI, {Size = rDoor.RightDoorClosed.Size, CFrame = rDoor.RightDoorClosed.CFrame}):Play()
			task.wait(1)
			local LeftDoorClosingSound = script.Parent.Doors.Floor1.LeftDoor.LeftDoor.ElevatorClosing
			local RightDoorClosingSound = script.Parent.Doors.Floor1.RightDoor.RightDoor.ElevatorClosing
			LeftDoorClosingSound:Play()
			RightDoorClosingSound:Play()
			wait(doorSpeed)
			
			local elevatorTI = TweenInfo.new(elevatorSpeed * math.abs(currentFloor - 2), Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
			tweenService:Create(cabin, elevatorTI, {CFrame = cabin.CFrame + Vector3.new(0, (doors["Floor2"].RightDoor.RightDoor.Position.Y - cabin.Position.Y), 0)}):Play()
			wait(0.6) -- How long before elevator sound plays
			local ElevatorCeiling = game.Workspace.ElevatorCeiling
			ElevatorCeiling.ElevatorSound:Play()
			wait(elevatorSpeed * math.abs(currentFloor - 2))
			task.wait(2)
			local LeftDoorOpeningSound = script.Parent.Doors.Floor2.LeftDoor.LeftDoor.ElevatorOpening
			local RightDoorOpeningSound = script.Parent.Doors.Floor2.RightDoor.RightDoor.ElevatorOpening
			LeftDoorOpeningSound:Play()
			RightDoorOpeningSound:Play()			
		end


		local lDoor = doors["Floor2"].LeftDoor
		tweenService:Create(lDoor.LeftDoor, doorTI, {Size = lDoor.LeftDoorOpened.Size, CFrame = lDoor.LeftDoorOpened.CFrame}):Play()
		local rDoor = doors["Floor2"].RightDoor
		tweenService:Create(rDoor.RightDoor, doorTI, {Size = rDoor.RightDoorOpened.Size, CFrame = rDoor.RightDoorOpened.CFrame}):Play()
		wait(doorSpeed)
		currentFloor = 2
		elevatorMoving = false
		table.remove(elevatorQueue, 1)
		script:Destroy()
	end
end

I’d truly appreciate your help on this as I’ve been stressing like crazy over this the past few days and is holding me back so much!

1 Like

Hello! This is because the physics of the elevator isn’t being applied to the player.
You may want to try using vectorforce of vectorpositions to physically-based move the elevator instead of using tweenservice, or updating cframe’s manually, as this doesn’t apply physics to the parts, thus not applying the physics to the player.

You would probably need a singular part as the “primarypart” and the rest are welded to it. Make sure the parts are all not anchored. You can use a mix of the vector objects I told about to keep the elevator still on floors, and use tweenservice to tween forces if you want it as “animated” as your video shows (where its slow at first, fast, than slow at the end).

I have little understanding on how to get these objects to stop moving at the position you want, mostly because I learned bodymovers/physics over vector, but bodymovers are now deprecated.

I wanna add that the player is shaking because the game gets confused to whether or not the players falling, since the platform below them is moving downwards.

The second video very clearly shows this, because the platform is moving faster than the player’s fall speed, so it looks like the player is jumping.

1 Like

Yeah all the parts you seen inside the elevator including the walls, floor, bars on the side, and light, are all welded to the main part called “Cabin” which is the invisible part covering the entire interior of the elevator.

How would I go about implementing this Vector objects thing? Sorry, bit confused on that still.

I’m not at all familiar with VecorForce, but maybe reading this document will help.

I’ve made something in the past with bodyvelocity that was slightly similar (a bunch of moving platforms, where they stop at a spot, and then go reverse), which is the deprecated version of the vector objects, like VectorForce.

Basic it pushes the object with an invisible force in a direction you specify.
You can check the cframe of your elevator every frame, if it is at (or within margin of error of) the spot you want it to stop, set the velocity to 0.

Use a gyro force ( I think?) to keep the object at that spot, and at the right rotation (as normally the object will rotate a lot).

The difference between vector and the body objects is that the body objects in the past applied to the center of the part it was under. The vector objects apply the force to an attachment you place. This can be anywhere, but I usually would probably keep it at the center. You will need to place an attachment, though.

I hope this help