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

How do you Teleport a Player from Game to Game?

How do you Teleport a Player from Game to Game? I would like to know and understand a Script that allows you to click a Button which would Teleport you from the Game you are currently in to a different game.

2 comments

0

Please give an example. I am very new to Lua Scripting and I do not understand this particular Script.

3 answers

✓ Accepted answer

Because Dawn did not explain his script and Finick did not do it for when you click a button, or explain his script. Here.

local ts = game:GetService('TeleportService') -- Get the Teleport Service
local placeid = 123 -- Replace with your PlaceId

function clicked(playerWhoClicked) -- Handle being clicked
	ts:Teleport(placeid,playerWhoClicked) -- Teleport the player
end -- End the function

script.Parent.ClickDetector.MouseClick:connect(clicked) -- Run the Function once clicked

6 comments

0

Thank you!

0

I only have one question. What do I enter for TeleportService? Do I enter the Part that is being clicked?

0

You're only supposed to edit the placeid, and the script.Parent.ClickDetector part.

0

What am I supposed to enter for the script.Parent.ClickDetector part?

0

For example, if you have a Part in Workspace named Part, and there's a ClickDetector inside it do game.Workspace.Part.ClickDetector

0

Nevermind! It worked! I accidentally placed my Script in the ClickDetector!

Problem Il make the script but this is not a request site.

function teleport(placeid, player)
game:GetService('TeleportService'):Teleport(placeid,player)
end

1 comment

0

Where do I type in the Game ID?

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
	game:GetService("TeleportService"):TeleportToSpawnByName((281925931), "(SpawnLocation)", player)
    end
end
 
script.Parent.Touched:connect(onTouched)

3 comments

0

Spawn point? Can you please repeat the same thing but please put example IDs in the Script.

0

ok ...

0

ok, i changed it :)

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