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

How do I make select a player script?

Hi, So I need a script for my game where at the beginning of each round it picks a random player to be a killer, and I don't know how to do this, can you guys pls kind of give an example or what to type on the wiki, Thanks! :D

1 answer

✓ Accepted answer

You need to use math.random to pick a random player.

p = game:GetService("Players"):GetChildren()
randplayer = p[math.random(1,#p)]
print(randplayer.Name)

Please accept if this helped!

4 comments

0

will it save that rand player.

0

This just an example. Read the wiki to find out how to do that.

0

GetPlayers() not GetChildren

0

Works too, why would you put anything else in the Players service?

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