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 select a random player?

I was googling this, and I found a previous question that asked the same thing, but the answer did not work for me. the script that is running this code is in ServerScriptService, and I want to access a folder within that player

local Plrs = game.Players:GetPlayers()
Plr1 = Plrs[math.random(1,#Plrs)] 
Plr1.Settings.IsSelected.Value = true

2 comments

0

Try doing print(Plr1). What does it print?

0

I tried that before, it does nothing. not even an error

1 answer

✓ Accepted answer

Easy and simple answer: Click here for answer

In the link above,

this = game.Players

local p = this:GetChildren()
        for i = 1,#p do
            b = math.random(1,i)
            print(b)
	    p[b].Settings.IsSelected.Value = true
        end
end

Basically loops the players and gets one then changes the players settings is selected value to true, If this helped, upvote + answer would be appreciated. Thank you, bye

2 comments

0

use getplayers() instead

0

It could be done either way ^

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