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

How to teleport a player randomly between two games?

Asked by 6 years ago

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
0
Have you tried on an actual server rather than roblox studio test mode? Le_Teapots 913 — 6y
0
yes lolkid007 43 — 6y
0
damn this question be spam DeceptiveCaster 3761 — 6y
0
.-. lolkid007 43 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

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.

1
Local variables are faster than normal ones, why wouldn't you use them, and in this script for sure.. User#20388 0 — 6y
0
I'm more used to using regular variables, maybe so... DeceptiveCaster 3761 — 6y
1
You cant tell someone to stop doing something just because of your preference. Axceed_Xlr 380 — 6y
Ad

Answer this question