@Black_Albi After you’ve modified my script you made some errors and added some inutil “else”, anyways this is the working script:
local TeleportPositionUp = script.Parent.Elevator2.DetectionArea
local TeleportPositionDown = script.Parent.Elevator.DetectionArea
local buttonInFirst = script.Parent.Elevator.Prox2.ProximityPrompt
local buttonInSecond = script.Parent.Elevator2.Prox2.ProximityPrompt
local waitTime = 15
local down = true
local debounce = false
local soundp = script.Parent.Elevator2.Door1.ElevatorSound
buttonInFirst.Triggered:Connect(function()
if debounce == false then
debounce = true
if down == true then
soundp:Play()
print("Going up")
--Close doors tween here
wait(waitTime)
for _, players in pairs(game.Players:GetPlayers()) do
if script.Parent.Elevator.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPositionUp.CFrame
end
end
down = false
debounce = false
--Open doors tween of the elevator2 here
end
end
end)
buttonInSecond.Triggered:Connect(function()
if debounce == false then
debounce = true
if down == false then
--Close doors tween here
soundDown:Play()
print("Going down")
wait(waitTime)
for _, players in pairs(game.Players:GetPlayers()) do
if script.Parent.Elevator.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPositionDown.CFrame
end
end
down = true
debounce = false
--Open doors tween of the elevator1 here
end
end
end)
script.Parent.Elevator2.Prox1.ProximityPrompt.Triggered:Connect(function()
if debounce == false then
debounce = true
if down == false then
--Close doors tween of the elevator2 here
soundp:Play()
wait(waitTime)
down = true
debounce = false
--Open tween of the elevator1 here
end
end
end)
script.Parent.Elevator2.Prox2.ProximityPrompt.Triggered:Connect(function()
if debounce == false then
debounce = true
if down == true then
--Close doors tween of the elevator1 here
soundp:Play()
wait(waitTime)
down = false
debounce = false|
--Open tween of the elevator2 here|
end
end
end)
I just encountered a little problem with the outside button :
So first, It always teleport player into the elevator.
2, It doesn’t detect if the elevator is down (teleport player down to up) or if it’s up (teleport player up to down)
Yep, inside elevator works, Now I’m trying to do the outside elevator to call the elevator (or troll your mate by making it go down) so If the elevator up is here (doors open) you close them and make everybody inside go down, same thing if it’s down. Problem is that even if you don’t touch the part it’ll tp you.
local TeleportPositionUp = script.Parent.Elevator2.DetectionArea
local TeleportPositionDown = script.Parent.Elevator.DetectionArea
local buttonInFirst = script.Parent.Elevator.Prox2.ProximityPrompt
local buttonInSecond = script.Parent.Elevator2.Prox2.ProximityPrompt
local buttonOutFirst = script.Parent.Elevator.Prox1.ProximityPrompt
local buttonOutSecond = script.Parent.Elevator2.Prox1.ProximityPrompt
local TeleportPositionUp = script.Parent.Elevator2.DetectionArea
local TeleportPositionDown = script.Parent.Elevator.DetectionArea
local buttonInFirst = script.Parent.Elevator.Prox2.ProximityPrompt
local buttonInSecond = script.Parent.Elevator2.Prox2.ProximityPrompt
local waitTime = 15
local down = true
local debounce = false
-- If pos == true, then elevator is down, false means it is up
local goal = {}
local goal2 = {}
local goal3 = {}
local goal4 = {}
local goal5 = {}
local goal6 = {}
local goal7 = {}
local goal8 = {}
local TS = game:GetService("TweenService")
local part = script.Parent.Elevator.Door1
local part2 = script.Parent.Elevator.Door2
local part3 = script.Parent.Elevator2.Door1
local part4 = script.Parent.Elevator2.Door2
goal.Position = script.Parent.Elevator.Door1.Position -- Opened door 1
goal2.Position = script.Parent.Elevator.Door1.Position + Vector3.new(0,0,6.05) -- Closed door 1
goal3.Position = script.Parent.Elevator.Door2.Position -- Opened door 2
goal4.Position = script.Parent.Elevator.Door2.Position - Vector3.new(0,0,6.05) -- Closed door 2
-- Elevator 2
goal5.Position = script.Parent.Elevator2.Door1.Position + Vector3.new(0,0,6.05) -- Opened Door 1
goal6.Position = script.Parent.Elevator2.Door1.Position -- Close Door 1
goal7.Position = script.Parent.Elevator2.Door2.Position - Vector3.new(0,0,6.05) -- Open door 2
goal8.Position = script.Parent.Elevator2.Door2.Position -- Close Door 2
local tweenInfo = TweenInfo.new(3)
local tween = TS:Create(part, tweenInfo, goal)
local tween2 = TS:Create(part, tweenInfo, goal2)
local tween3 = TS:Create(part2, tweenInfo, goal3)
local tween4 = TS:Create(part2, tweenInfo, goal4)
local tween5 = TS:Create(part3, tweenInfo, goal5)
local tween6 = TS:Create(part3, tweenInfo, goal6)
local tween7 = TS:Create(part4, tweenInfo, goal7)
local tween8 = TS:Create(part4, tweenInfo, goal8)
local soundDown = script.Parent.Elevator.Door1.ElevatorSound
local soundp = script.Parent.Elevator2.Door1.ElevatorSound
buttonInFirst.Triggered:Connect(function()
if debounce == false then
debounce = true
soundDown:Play()
print("Going up")
tween2:Play()
tween4:Play()
tween6:Play()
tween8:Play()
wait(waitTime)
for _, players in pairs(game.Players:GetPlayers()) do
if script.Parent.Elevator.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPositionUp.CFrame
end
end
debounce = false
tween5:Play()
tween7:Play()
end
end)
buttonInSecond.Triggered:Connect(function()
if debounce == false then
debounce = true
tween2:Play()
tween4:Play()
tween6:Play()
tween8:Play()
soundp:Play()
print("Going down")
wait(waitTime)
for _, players in pairs(game.Players:GetPlayers()) do
if script.Parent.Elevator2.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame =TeleportPositionDown.CFrame
end
end
tween:Play()
tween3:Play()
debounce = false
end
end)
buttonOutFirst.Triggered:Connect(function()
if debounce == false then
debounce = true
tween2:Play()
tween4:Play()
tween6:Play()
tween8:Play()
soundp:Play()
print("Waiting for the elevator")
for _, players in pairs(game.Players:GetPlayers()) do
if down == true then
if script.Parent.Elevator2.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame =TeleportPositionDown.CFrame
elseif down == false then
if script.Parent.Elevator2.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame =TeleportPositionDown.CFrame
end
end
end
wait(waitTime)
tween5:Play()
tween7:Play()
print("Opening doors")
debounce = false
end
end)
buttonOutSecond.Triggered:Connect(function()
if debounce == false then
debounce = true
tween2:Play()
tween4:Play()
tween6:Play()
tween8:Play()
soundp:Play()
print("Waiting for the elevator")
wait(waitTime)
for _, players in pairs(game.Players:GetPlayers()) do
if down == true then
if script.Parent.Elevator2.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame =TeleportPositionDown.CFrame
elseif down == false then
if script.Parent.Elevator2.DetectionArea.Touched then
players.Character:WaitForChild("HumanoidRootPart").CFrame =TeleportPositionDown.CFrame
end
end
end
tween:Play()
tween3:Play()
print("Opening doors")
debounce = false
end
end)
Sorry for the delay
So the sript was a bit outdated cuz I’m editing it on a new baseplate (computer restarted so lost everything and had to make one quickly) The problem is that it tp the player EVEN if he’s not inside the elevator, and it doesn’t tp him in the next elevator, but at the elevator where the button is
The way you made the inside button was smart, cuz to get access to the inside button, the elevator have to be up or down. But on the outside button, we have to call the elevator/make it go depending on if the elevator is up or down. then get the player inside and tp him