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

How to teleport a player randomly between two games?

I have a script where it will teleport the player after 10 seconds randomly between two games, but the script will not teleport to a different game and in studio it tells me GameNotFound. Script:

local TeleportService = game:GetService("TeleportService")
local gameID = 1537690962
local player = game.Players.LocalPlayer
local gameId = 1537690962

wait(10)

local random = math.random(2) -- Randomly chooses either 1 or 2

if random == 1 then
    TeleportService:Teleport(gameID, player)
elseif random == 2 then
    TeleportService:Teleport(gameId, player)
end

4 comments

0

Have you tried on an actual server rather than roblox studio test mode?

0

yes

0

damn this question be spam

0

.-.

1 answer

Make a list of Place IDs:

list = {"000000000", "000000000"}
clickdetect = script.Parent -- I prefer to use ClickDetectors because they are easier to control than Touched events that require debounce techniques
tpservice = game:GetService("TeleportService")
function Teleport(player)
	for i = math.random(1, #list) do
		tpservice:Teleport(tonumber(list), player)
		wait(1) then break
	end
end
clickdetect.MouseClick:Connect(Teleport)

And PLEASE stop using local variables. You people clearly don't understand Lua 5.1.

3 comments

1

Local variables are faster than normal ones, why wouldn't you use them, and in this script for sure..

0

I'm more used to using regular variables, maybe so...

1

You cant tell someone to stop doing something just because of your preference.

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