So I made an elevator system where the player teleports to another place and added an exit button to exit the elevator. The player’s HumanoidRootPart’s CFrame would then be set as the CFrame of another part (the tp part is inside of the elevator model), but whenever I exit the elevator, I’m sent to the CFrame of another elevator instead. It’s the same issue for every elevator. Whenever I leave, I’m always sent to the CFrame of the tp part of the elevator in the back right of the lobby, and I’m not sure why. There are no error messages.
I would attach a video but there’s an issue with attaching videos for some reason
Here’s the script the issue should be coming from:
elevatorEvent.OnServerEvent:Connect(function(player)
local isWaiting = table.find(playersWaiting, player)
if isWaiting then
table.remove(playersWaiting, isWaiting)
end
playersGui.Container.NumberOfPlayers.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
if player.Character then
player.Character.PrimaryPart.CFrame = config.TeleportOut.Value.CFrame
end
end)
Did you make sure the “TeleportOut” value is set to the correct part?
Also, I would recommend using player.Character:PivotTo(config.TeleportOut.Value.CFrame) instead. :PivotTo() will move the entire model instead of just the primary part, which could cause some issues.
The config is a configuration folder inside of my elevator model that held my MaxPlayers value and the value of the part I wanted players to teleport out to (which is what the TeleportOut.Value was), but TeleportOut wasn’t part of my config folder, it was just an attempt and fixing the issue somehow since I thought it was a studio bug. Here’s the updated script (the issue still isn’t fixed):
elevatorEvent.OnServerEvent:Connect(function(player)
local isWaiting = table.find(playersWaiting, player)
if isWaiting then
table.remove(playersWaiting, isWaiting)
end
playersGui.Container.NumberOfPlayers.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
if player.Character then
player.Character:PivotTo(elevator.TeleportOut9.CFrame)
end
end)
The TeleportOut9 is the part I want players to teleport out to. I have a different one named something different for each elevator, since I have 9 elevators, I made a TeleportOut part for each elevator, they’re named TeleportOut1, TeleportOut2, etc. just so they’d have different names
You can use an ObjectValue, to get the instance in value, and then just choose the object you want it to teleport to by taking its “Value” and then get your CFrame from the instance
So the issue is basically that when the player clicks the gui to teleport out of the elevator, they’re teleporting to the TeleportOut part of a completely different elevator. For some reason, when the player teleports out of an elevator, no matter what elevator they’re teleporting out of, their CFrame is set to the CFrame of a TeleportOut part of one particular elevator. I’ll show you how it’s organized as a visual representation if that’s easier to see:
He is teleporting to another elevator, because all elevators exist with the same name, and so he takes another elevator that seems to be the same as the one he was doing so whenever he wants to leave he will take the instance of another one with the same name of model
Why don’t you try to make it automated?, for example, you can make him be pushed into the elevator he stepped on and placed inside a table with other players ← that’s what you did, check above which elevator he is inserting an ObjectValue with the value of the elevator he is doing like this taking the model and getting the “TeleportOut”
The issue with that is I already have a somewhat working system where the player gets put into the elevator when touching a part, I’ll show the part of the script where that happens, but for some reason when I use the same script but for exiting, it doesn’t work
Here’s the entering and exiting script:
elevator.Entrance.Touched:Connect(function(part)
local player = Players:GetPlayerFromCharacter(part.Parent)
local isWaiting = table.find(playersWaiting, player)
if player and not isWaiting and #playersWaiting < config.MaxPlayers.Value and not moving then
table.insert(playersWaiting, player)
playersGui.Container.NumberOfPlayers.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
player.Character.PrimaryPart.CFrame = elevator.TeleportIn.CFrame
elevatorEvent:FireClient(player, elevator)
if not countdownRunning then
RunCountdown()
end
end
end)
elevatorEvent.OnServerEvent:Connect(function(player)
local isWaiting = table.find(playersWaiting, player)
if isWaiting then
table.remove(playersWaiting, isWaiting)
end
playersGui.Container.NumberOfPlayers.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
if player.Character then
player.Character:PivotTo(elevator.TeleportOut9.CFrame)
end
end)
As you can see they’re very similar and the entering works just fine
Here is a basic elevator entry and exit system, with randomized entry and exit positions, and automatic, no matter how many elevators you want to create, it will always work.
I didn’t add anything teleporting, I just made the system that you were having difficulties with, if you want complete just answer me and I will complete it for you with a SubPlace teleport
If I managed to help you, give me a “Solution” on the side😁
You could use one event, but you would have to send which elevator to refer to when finding the TeleportOut part through the event. If you only have one event and its being listened to through each script, it’ll run the code for each elevator that your elevator variable refers to for each script when you use :FireClient().