The system of random selection of opponents

I want to make a system of matching two players who will fight each other. After the timer expires, 2 players teleport to the game area and begin the battle. Q: how can I do this? I’ve been trying to do this for the second day, but I haven’t seen anything like this on the forum that could help

1 Like

I will be glad of any help :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face:

You can just get all the players of the server, and just randomize an number based on the amount of players you have. Then it gets that player, and it teleports the players to like the arena


I tried to do this yesterday, but it gives me an error.

Do you can show the script and the error so i can fix the script?

2 is not a valid member of Player “Players.Szerpan”

You dont need a i,v in pairs for the players in the line 14

local choosenplayer1 = game.Players:GetPlayers(math.random(1,#game.Player:GetPlayers))
local choosenplayer2 = nil

repeat
choosenplayer2 = game.Players:GetPlayers(math.random(1,#game.Player:GetPlayers))
wait()
until
choosenplayer2.Name ~= choosenplayer1.Name

choosenplayer1.Character:PivotTo(clonemap.Teleport1.CFrame)
choosenplayer2.Character:PivotTo(clonemap.Teleport2.CFrame)

Thank you very much!. but why don’t I need i, v in pairs for players

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.