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

How can I teleport people between places in a game?

So in game explorer, under places, I have 2 places. One is the main game, and one is a separate game mode. How can I make it so you can teleport between these places with a gui?

2 answers

Ok I'm incredibly new to scripting, but this is something I have achieved in my own game, so I will show you the scripts I've got and where they go.

Firstly, you need a RemoteEvent in your ReplicatedStorage for teleporting.

Then, place a script like this in the ServerScriptService:

local debounce = false

game.Workspace.TeleportPart.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		if game.Players:GetPlayerFromCharacter(hit.Parent) then
			game.ReplicatedStorage.TeleportGUI:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
		end
		wait (2)
		debounce = false
	end
end)

Then, within your GUI button, put this:

script.Parent.MouseButton1Down:Connect(function()
	game:GetService("TeleportService"):Teleport(PLACE ID HERE)
end)

Mine is set up so that the GUI is shown on a part touch, which is within part of this script.

Basically, you need to add variables and make sure the player clicks the gui:

local Variable = game:GetService("TeleportService") -- teleport service


script.Parent.MouseButton1Down:Connect(function() -- player clicking the gui

end)

then add a service thing (dunno whats it called)

local Variable = game:GetService("TeleportService")

script.Parent.MouseButton1Down:Connect(function()
        Variable:Teleport(--placeID)
end)

very simple!

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