Elevator Movement Shakes

Can someone explain why this elevator shakes and how to fix it for a smoother ride? Thanks.

Here are the scripts.

Client script:

local ts = game:GetService("TweenService")

local topDoorStartPos = Vector3.new(0.811, 35.367, -435.086)
local topDoorEndPos = Vector3.new(0.811, 22.526, -435.086)

local bottomDoorStartPos = Vector3.new(0.811, -639.249, -435.086)
local bottomDoorEndPos = Vector3.new(0.811, -652.458, -435.086)

local elevatorStartPos = script.Parent:WaitForChild("ElevatorUpPos").CFrame
local elevatorEndPos = script.Parent:WaitForChild("ElevatorDownPos").CFrame
local elevatorMiddlePos = script.Parent:WaitForChild("ElevatorMiddlePos").CFrame

local elevator = script.Parent:WaitForChild("Elevator")
local topDoor = script.Parent:WaitForChild("TopDoor")
local bottomDoor = script.Parent:WaitForChild("BottomDoor")
local detector = elevator:WaitForChild("Detector")

local waitUpTime = 30
local waitDownTime = 30
local glassCloseTime = 2
local glassOpenTime = 2.75
local elevatorDownTime = 20
local elevatorUpTime = 20

local state = script.Parent:WaitForChild("State")

local function GetTouchingParts(part)
	local connection = part.Touched:Connect(function() end)
	local results = part:GetTouchingParts()
	connection:Disconnect()
	return results
end

local function tweenModel(model, cframe, time)
	local cframeValue = Instance.new("CFrameValue")
	cframeValue.Value = model:GetPrimaryPartCFrame()

	cframeValue:GetPropertyChangedSignal("Value"):connect(function()
		model:SetPrimaryPartCFrame(cframeValue.Value)
	end)

	local info = TweenInfo.new(time, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local tween = ts:Create(cframeValue, info, {Value = cframe})
	tween:Play()

	tween.Completed:connect(function()
		cframeValue:Destroy()
	end)
end

local function tweenModel2(model, cframe, time)
	local cframeValue = Instance.new("CFrameValue")
	cframeValue.Value = model:GetPrimaryPartCFrame()

	cframeValue:GetPropertyChangedSignal("Value"):connect(function()
		model:SetPrimaryPartCFrame(cframeValue.Value)
	end)

	local info = TweenInfo.new(time, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
	local tween = ts:Create(cframeValue, info, {Value = cframe})
	tween:Play()

	tween.Completed:connect(function()
		cframeValue:Destroy()
	end)
end

state:GetPropertyChangedSignal("Value"):Connect(function()
	if state.Value == "GlassUpClosing" then
		topDoor.CloseDoor:Play()
		ts:Create(topDoor, TweenInfo.new(glassCloseTime), {Position = topDoorEndPos}):Play()
	end
	if state.Value == "GoingDown" then
		--for i, part in next, GetTouchingParts(detector) do
		--	if part.Parent:FindFirstChild("Humanoid") then
		--		part.Parent.Archivable = true
		--		part.Parent.Humanoid.WalkSpeed = 0
		--		part.Parent.Parent = elevator.Players
		--		part.Parent.HumanoidRootPart.Anchored = true
		--	end
		--end
		
		tweenModel2(elevator, elevatorMiddlePos, elevatorDownTime / 2)
		
		task.wait(elevatorDownTime / 2)
		
		tweenModel(elevator, elevatorEndPos, elevatorDownTime / 2)
	end
	if state.Value == "GlassDownOpening" then
		bottomDoor.OpenDoor:Play()
		ts:Create(bottomDoor, TweenInfo.new(glassOpenTime), {Position = bottomDoorStartPos}):Play()
		
		--for i, part in next, GetTouchingParts(detector) do
		--	if part.Parent:FindFirstChild("Humanoid") then
		--		part.Parent.Parent = workspace
		--		part.Parent.HumanoidRootPart.Anchored = false
		--		part.Parent.Humanoid.WalkSpeed = 16
		--		part.Parent.Archivable = false
		--	end
		--end
	end
	if state.Value == "GlassDownClosing" then
		bottomDoor.CloseDoor:Play()
		ts:Create(bottomDoor, TweenInfo.new(glassCloseTime), {Position = bottomDoorEndPos}):Play()
	end
	if state.Value == "GoingUp" then
		--for i, part in next, GetTouchingParts(detector) do
		--	if part.Parent:FindFirstChild("Humanoid") then
		--		part.Parent.Archivable = true
		--		part.Parent.Humanoid.WalkSpeed = 0
		--		part.Parent.Parent = elevator.Players
		--		part.Parent.HumanoidRootPart.Anchored = true
		--	end
		--end

		tweenModel2(elevator, elevatorMiddlePos, elevatorUpTime / 2)
		
		task.wait(elevatorUpTime / 2)
		
		tweenModel(elevator, elevatorStartPos, elevatorUpTime / 2)
	end
	if state.Value == "GlassUpOpening" then
		topDoor.OpenDoor:Play()
		ts:Create(topDoor, TweenInfo.new(glassOpenTime), {Position = topDoorStartPos}):Play()
		
		--for i, part in next, GetTouchingParts(detector) do
		--	if part.Parent:FindFirstChild("Humanoid") then
		--		part.Parent.Parent = workspace
		--		part.Parent.HumanoidRootPart.Anchored = false
		--		part.Parent.Humanoid.WalkSpeed = 16
		--		part.Parent.Archivable = false
		--	end
		--end
	end
end)

Server script:

local waitUpTime = 30
local waitDownTime = 30
local glassCloseTime = 2
local glassOpenTime = 2.75
local elevatorDownTime = 20
local elevatorUpTime = 20

local state = script.Parent:WaitForChild("State")
local soundPart = script.Parent:WaitForChild("Elevator"):WaitForChild("SoundPart")

while true do
	task.wait(waitUpTime)
	state.Value = "GlassUpClosing"
	task.wait(glassCloseTime)
	task.wait(1)
	soundPart.elestart:Play()
	task.wait(1)
	state.Value = "GoingDown"
	soundPart.Elevator:Play()
	task.wait(elevatorDownTime - 3)
	soundPart.ArriveMainFacility:Play()
	task.wait(2.8)
	soundPart.Elevator:Stop()
	soundPart.eleend:Play()
	task.wait(0.2)
	task.wait(2)
	state.Value = "GlassDownOpening"
	task.wait(glassOpenTime)
	state.Value = "WaitingDown"
	task.wait(waitDownTime)
	state.Value = "GlassDownClosing"
	task.wait(glassCloseTime)
	task.wait(1)
	soundPart.elestart:Play()
	task.wait(1)
	state.Value = "GoingUp"
	soundPart.Elevator:Play()
	task.wait(elevatorUpTime - 3)
	soundPart.ArriveTopside:Play()
	task.wait(2.8)
	soundPart.Elevator:Stop()
	soundPart.eleend:Play()
	task.wait(0.2)
	task.wait(2)
	state.Value = "GlassUpOpening"
	task.wait(glassOpenTime)
	state.Value = "WaitingUp"
end

1 Like

Hi! Based on your video, I believe this is simply due to changing camera position, which makes sense as the object is moving, the camera needs to follow somehow. I remember doing a task like this and one thing I used was fade outs and fade in gui transitions so the player does not see the movement, and you can use a teleportation instead of movement. However, in your case perhaps could think of adjusting the CFrame to match the movement of the platform. If I recall correctly, the primary issue is that the CFrame adjustment is not taking into account Roblox Physics, hence why it is shaking. I think this post has an elegant system of incorporating CFrame change into moving objects. I hope this helps!

1 Like

Thanks for trying to help and sorry for the late response, but we already use that. Do you know any other solutions for this problem?

1 Like

I see, in that case have you tried to checking what happens when the elevator goes slower? It could have something to do with its speed being too fast?

1 Like

Of course, it would probably not shake anymore or shake minimum when it would go slow but I want the elevator to still be going fast.

@RealCalculus

Are you still interested in helping me on this?

1 Like