Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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. :)

2 comments

0

Thanks!

0

You're welcome, don't forgot to accept my answer and upvote it if it helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.