Rolepicker system help

 local Weapon = game.SeverStorage.Knife

local plrs = game.Players

 While Wait( ) do
local chosen = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]

I now little about scripting but just need some help on this script, what more is there to add, I’m still learning and I don’t know what to do to make this work fully I just now this part, can I have some help.

1 Like

So, you’re trying to pick a random player, and put them in a table?

The syntax for the script is wrong, it should look like this:

local Weapon = game.SeverStorage.Knife

local plrs = game.Players

while wait() do
  local chosen = plrs:GetPlayers()[math.random(1, #plrs:GetPlayers())]
  local character = chosen.Character
end

What this script does is chooses a random player. You can refrence the character by doing chosen.Character

For Character I would put plrs?

No, the character would be chosen.Character

1 Like

@crashedthe911 Right! That’s what I’m trying to accomplish.

Ok, Thanks for the help, I appreciate it.

1 Like
local Players = game.Players:GetPlayers()
for _ , Players in pairs(game.Players:GetPlayers()) do
        local GettingPlayer = Players[math.random(1,#Players]

This is basically the same to what @DatabaseReplace said, however a slightly different way of doing it.

Also, if you want to learn more about picking stuff randomly, look at this post.

3 Likes

@crashedthe911 Thanks for the help, and the post I will definitely be looking at.