How do I make a system where two people are randomly selected to fight?

Hello, I’m trying to make a system where two people are teleported into a ring and have to fight to the death, after one dies, they are both teleported to spawn. I’m having trouble making this and help will be appreciated.

You can use Players:GetPlayers to get all the players currently in the game and math.random to select random players. Get the players’ characters and teleport them to wherever the ring is. You can detect when someone dies and then teleport them back to the spawn.

1 Like

You can make a function to get a random player like this:

function getRandomPlayer()
	local players = game.Players:GetPlayers()
	local selectedPlayer = players[math.random(1,#players)]
	return selectedPlayer

local Plr1 = getRandomPlayer()
local Plr2 = getRandomPlayer()

to check if plr2 isn’t plr1, you can use a loop to get another player

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