How do I get the Nextnteger to pick a random player from game.Players?
This is a module script btw
The error message I got from this module is: ServerScriptService.Script.GiveRole:5: attempt to get length of a Instance value
function module.ChooseCEO(player)
local random = Random.new()
local chooseCEO = player[random:NextInteger(1, #game.Players)]
local SV = Instance.new("StringValue")
SV.Parent = player
SV.Name = "CEO"
return chooseCEO
end
return module```
local selectedPlayer = game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())]
This gets a random player in the server. Replace game.Players:GetPlayers() with the table you wish to pick players from (If I understand your problem right)
I would use GetService() but I’m on mobile and I’m too lazy to type that