I took the teleport brick from the wiki's tutorials page and altered it slightly to create a teleport to switch to the other game in my multi place game. I used this code:
local destinationBrick = game.Workspace:FindFirstChild(script.TeleportTo.Value)
script.Parent.Touched:connect(function(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then otherPart.Parent:MoveTo(147560488) end end)
What's wrong with it?
Firstly, replace the TeleportTo value
with an IntValue
or a NumberValue
of the same name
.
In that new value, put in the place ID
of the place you want to go to and replace the code in your script with this:
local newPlace = script:WaitForChild("TeleportTo") --In case the TeleportTo IntValue script.Parent.Touched:connect(function(hit) --When something touches the parent of the script. local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Get the player from the parent of the part that touched the script's parent. if player then --If the player is found then. game:GetService("TeleportService"):Teleport(newPlace.Value, player) --Gets the TeleportService and teleports the player to the place ID in the value of TeleportTo in the script. end --End the if statement in the function. end) --End the function's code, this is the end of the file.
I hope this helped you, you can accept my answer if it helped you and you can also upvote it. :)