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

How would you teleport players like a dueling position?

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??

1 answer

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()

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