Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Ho do you do math.random but with players? I want to select a random player for the script

I wan't to select a random player for the script to execute on. How would I do that?

1 answer

✓ Accepted answer

You can put all the players in a table, then do a math.random. Below is a simple script where it would print a random name every second.

while wait(1) do
	local players = game.Players:GetPlayers() --getting the players
	local person = math.random(1,#players) --getting a number from 1 to the amount of elements in the table
	print(players[person]) --prints the element in that position
end

Hope this helps!

1 comment

0

ys

This discussion is preserved as it was. New answers, comments, and votes are closed.