I'm trying to make a game that will teleport two players into an arena to fight. I've already made the script although whenever I run it sometimes it would only teleport one player. I want to grab two players that are not the same. This is my attempt
local NumbPlayers = #game.Players:GetPlayers()
if NumbPlayers >= 2 then
local randomPlayer1 = game.Players:GetPlayers()
[math.random(1,#game.Players:GetPlayers())]
local randomPlayer2 = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
print(randomPlayer1)
print(randomPlayer2)
if randomPlayer2 == randomPlayer1 then
randomPlayer2 = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
end
end
I do have a bit of a precaution that if randomplayer2 is equal to randomplayer1 then it will choose a new player. Although sometimes that doesn't even work. Any help would be apreciated
Regards, Bl_ueHistory

1 comment
Note I would probably also put all of this in a function and just return the First and Second player chosen, this way the Players table will get updated with current players in the server.