I need a script to pick a random person from a server, and make it repeat with different people at a time
while wait(1)do if game.Players.NumPlayers>0 then local chosen=game.Players:GetPlayers()[math.random(1,game.Players.NumPlayers)] print(chosen) end end
This will print a random player in the game every second. Unfortunately it can't pick different people at a time while only picking a single random person because that is logically impossible.
You could try taking everyone, and putting them in a table! Of course, you still need to constantly update the table based on who is in the server! Then select randomly from the table! Once you select the person, remove them from the table so they can't be picked again! Although, I probably wrote the code a tad bit ineffeciently then it should be, I would normally do something along the lines of:
bob = {} function reupdate() bob = {} for _,v in pairs(game.Players:GetPlayers()) do table.insert(bob,v.Name) end end function pickRandom() for i,k in pairs(bob) do s = math.random(1,#bob) return s table.remove(bob,s) end end game.Players.PlayerAdded:connect(function(p) reupdate() end) game.Players.PlayerRemoving:connect(function(s) reupdate() end)