How to pick several random players

I am currently working on a Plates of Fate/Horrific Housing game. One Issue I seem to be facing so far is how I can pick several players for an effect. For example, “Username and Username have recived swords!” This seems to be one of the main roadblocks I’ve hit and I can’t seem to get past it.

Loop through a bunch of players, and for each one, generate a random number between 1 and x. If their number is greater than y, do whatever, give them an item, brutally kill them, etc.

local count = 0
game.Players.PlayerAdded:Connect(function(plr)
 for i,v in pairs(game.Players:GetChildren()) do
  count = count + 1
 end
 local choice = math.random(1,count)
end)

something like that should work!

1 Like

Get a table of players using Players:GetPlayers(). Get some random indexes from this table and remember to remove the chosen index from the table everytime you choose, to prevent the same player getting chosen.