I create an elevator. The parts roll onto the elevator. Then the elevator goes up. But the parts that rolled onto the elevator part does not move with the elevator up. It’s like the elevator part moves through the parts that roll onto it. Can someone please help me?
local elevator = script.Parent.Elevator
local door1 = script.Parent.Door1
local door2 = script.Parent.Door2
– Store the elevator’s initial position
local initialElevatorPosition = elevator.Position
local TweenService = game:GetService(“TweenService”)
local debounceTime = 10 – Set the debounce time in seconds
local lastActivation = os.time() - debounceTime
local function MoveElevatorUp()
local targetPosition = initialElevatorPosition + Vector3.new(0, 8.6, 0)
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
local tween = TweenService:Create(elevator, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function MoveElevatorDown()
local targetPosition = initialElevatorPosition
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
local tween = TweenService:Create(elevator, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function OpenDoor1()
local targetPosition = door1.Position + Vector3.new(0, 3.5, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(door1, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function CloseDoor1()
local targetPosition = door1.Position - Vector3.new(0, 3.5, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(door1, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function OpenDoor2()
local targetPosition = door2.Position + Vector3.new(0, 4, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(door2, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function CloseDoor2()
local targetPosition = door2.Position - Vector3.new(0, 4, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(door2, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait(0.1)
end
local function ActivateElevator()
local currentTime = os.time()
if currentTime - lastActivation >= debounceTime then
lastActivation = currentTime
CloseDoor1()
MoveElevatorUp()
OpenDoor2()
wait(2)
CloseDoor2()
MoveElevatorDown()
OpenDoor1()
end
end
local button = script.Parent.Button
local proximityPrompt = button:WaitForChild(“ProximityPrompt”)
proximityPrompt.Triggered:Connect(ActivateElevator)