 0  # How would you teleport players like a dueling position? Lem0nzz 5
9 years ago

local players = game.Players:GetPlayers() local random = players[math.random(2, #players)]

How would you get the 2 players you picked, to go to side1, and side2??

2   AmericanStripes 610 9 years ago

First you will need to Vector3 positions of the place you want each player to teleport to, and set up some variables

pos1 = -- Vector3 Position Here
pos2 = -- Vector3 Position Here

play1 =  --Leave blank
play2 =  --Leave blank


After that, we need to get some random players!

function RandomPlayer()
local player = {}
for _,v in pairs(game.Players:GetChildren()) do
table.insert(player, v)
end

local num = player[math.random(1,#player)]
local num2 = player[math.random(1,#player)]

if num == num2 then
repeat local num2 = player[math.random(1,#player)] until num ~= num2
end

play1 = num
play2 = num2
end


Most likely a bit much to just get 2 players, but oh well!

Now we need to teleport them!

function Move()
play1.Character:MoveTo(pos1)
play2.Character:MoveTo(pos2)
end


Now if we put that together:

pos1 = -- Vector3 Position Here
pos2 = -- Vector3 Position Here

play1 =  --Leave blank
play2 =  --Leave blank

function RandomPlayer()
local player = {}
for _,v in pairs(game.Players:GetChildren()) do
table.insert(player, v)
end

local num = player[math.random(1,#player)]
local num2 = player[math.random(1,#player)]

if num == num2 then
repeat local num2 = player[math.random(1,#player)] until num ~= num2
end

play1 = num
play2 = num

return true
end

function Move()
play1.Character:MoveTo(pos1)
play2.Character:MoveTo(pos2)
end

RandomPlayer()
repeat wait() until RandomPlayer()

Move() 