Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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

If anyone can help it'd be awesome!

0
Can you post the script? Farsalis 369 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question