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 want a script to teleport a player to game #1 or game #2 but I was never really good with randomizers. Here is script it's a little bit messy:

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

math.random(10,20)
wait(math.random)

local random = math.random(0,1)
if random > 1 then
        TeleportService:Teleport(gameID, player)
    end

if not random <= 1 then
    TeleportService:Teleport(gameId, player)
end

1 answer

Log in to vote
0
Answered by 6 years ago
local TeleportService = game:GetService("TeleportService")
local gameID = 1766746368
local player = game.Players.LocalPlayer
local gameId = 1766751281

wait(math.random(10, 20)) -- Randomly chooses an integer between 10 and 20

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
Ad

Answer this question