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:
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!