First of all, don't get intimidated by the size of the script, it's actually pretty much the same code everywhere. So.. Whenever I run this script, it prints the tables at the end if there are enough players, but it doesn't print out what it's supposed to. Actually, the output should print out at least three players in the werewolves table, but instead, it doesn't print out anything. I need some pros to help me
local Players = game:GetService("Players")
local Roles = game.ReplicatedStorage.roles:GetChildren()
Villagers = {}
Werewolves ={}
Arsonists = {}
Hunters ={}
Mediums ={}
Seers ={}
Jesters ={}
Witches ={}
Minimumwolves = 3
Werewolvescount = table.getn(Werewolves)
MaximumSeers = 1
MaximumArsonists = 1
MaximumJesters = 1
game.Players.PlayerAdded:Connect(function(plr)
local NeedsRole = Instance.new("BoolValue")
NeedsRole.Name = ("NeedsRole")
NeedsRole.Parent = plr
NeedsRole.Value = true
print("Just joined: "..plr.Name)
if table.getn(Players:GetChildren()) == 1
then
print("There are "..table.getn(Players:GetChildren()).." Players, choosing Roles!")
wait(1)
print("...Choosing...")
wait(3)
for _,player in pairs(Players:GetChildren())
do
local ChooseTable = math.random(1,8)
player.NeedsRole.Value = true
if ChooseTable == 1 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Villagers,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 2 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Werewolves,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 3 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Arsonists,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 4 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Hunters,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 5 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Mediums,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 6 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Seers,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 7 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Jesters,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
elseif ChooseTable == 8 and Werewolvescount >= 3
then
if player.NeedsRole.Value == true
then
table.insert(Witches,1,player)
player.NeedsRole.Value = false
else
if Werewolves <3 then
table.insert(Werewolves,1,player)
end
print(player.Name.." already has a role!")
end
end
end
print("")
print("ROLETABLES AFTER ASSIGNMENT!:")
print("")
print("Villagers: ")
print(table.unpack(Villagers))
wait(1)
print("Werewolves: ")
print(table.unpack(Werewolves))
wait(1)
print("Arsonists: ")
print(table.unpack(Arsonists))
wait(1)
print("Hunters: ")
print(table.unpack(Hunters))
wait(1)
print("Mediums: ")
print(table.unpack(Mediums))
wait(1)
print("Seers: ")
print(table.unpack(Seers))
wait(1)
print("Jesters: ")
print(table.unpack(Jesters))
wait(1)
print("Witches: ")
print(table.unpack(Witches))
else
print("Not enough players!")
end
end)
Thanks in advance!

3 comments
Before I can answer this, instead of using the table.unpack method, use #table and say the results. Just to be sure about something.
Should i put "#table" in the print function?
it prints 0 everywhere