I know, this question is kind of similar to my last one, but I think I didn't explain well enough where my problem is. I want to assign certain players to random tables, and not random players to certain tables. I have absolutely no idea how to do it.

local Players = game:GetService("Players")
local Roles = game.ReplicatedStorage.roles:GetChildren()
local Playerstable = game.Players:GetPlayers()

Villagers = {}
Werewolves ={}
Arsonists = {}
Hunters ={}
Mediums ={}
Seers ={}
Jesters ={}
Witches ={}

function Randomizeplayer()
local Randomplayer = Players:GetChildren()[math.random(1,#Players:GetChildren())]
print(Randomplayer)
if table.getn(Werewolves) < 3
then
	table.insert(Werewolves,1,Randomplayer)
	print(table.unpack(Werewolves))
    print(table.unpack(Villagers))
else
	table.insert(Villagers,1,Randomplayer)
	print(table.unpack(Werewolves))
    print(table.unpack(Villagers))
end
end


game.Players.PlayerAdded:Connect(Randomizeplayer)

Thanks in advance!

9 comments

0

You can place your tables in an array, and from there use math.random to get a random table

0

I tried that, but it didn't work.

0

nvm

0

let me test that

0

How do you access an array within an array

0

Use math.random like Spjure said

0

I just found out the difference, so I mean a dictionary, not an array

0

access and array in a array = ARRAY[x][y]

0

dict[random(a,b)[random(c,d)]