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

How do i make a script too chose a random player in the server and get the players name?

I've been trying but i cant get it right it only shows numbers.

If anyone can help it'd be awesome!

1 comment

0

Can you post the script?

1 answer

Here: Make the script a normal script(not local). Then what you got to do is put some sort of function that waits a little while for the players to load. When you have got a specific number of players, put them into an array where some number corresponds to their name. Then make a math.random function with the input being the length of the array that gets a random number. With that number, you look for what name is at that value and you print it. Here is a link for arrays: https://developer.roblox.com/en-us/articles/Table

and here is a script that will go through all the players

players = game:GetService("Players")

for i, v in pairs(players:GetChildren() do
	print v.Name
end)

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