Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a teleport for my multi place game?

Asked by 9 years ago

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?

1 answer

Log in to vote
2
Answered by 9 years ago

Firstly, replace the TeleportTo value with an IntValueor 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. :)

0
Thanks! Theepicpaintballer5 0 — 9y
0
You're welcome, don't forgot to accept my answer and upvote it if it helped. Spongocardo 1991 — 9y
Ad

Answer this question