I am making a mafia type game where the murderer votes one person out each night. I have everything set up except for the fact that the bottom part of my code doesn't seem to be working. There are no error messages but I want the bottom of the code to take all the innocent players names and put them into values. This code is located in the serverscriptservice as a normal script. Can somebody help me? Thanks!
Here is the code. I am focusing on the bottom of the code:
local plrs = game.Players
local survivors = {}
local alreadypicked = false
while wait(10) do
if alreadypicked == false then
alreadypicked = true
local chosen = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
chosen.PlayerGui.Picker.Background.RoleGiven.Text = "Murderer"
chosen.PlayerGui.Picker.Background.othertext.Text = "You Are The"
chosen.PlayerGui.Picker.Background.RoleGiven.TextColor3 = Color3.fromRGB(255, 0, 0)
print(chosen.Name)
game.Workspace.murderername.Value = chosen.Name
chosen.PlayerGui.Picker.Background.Visible = true
for i, plr in pairs(plrs:GetChildren()) do
if plr ~= chosen then
table.insert(survivors, plr)
plr.PlayerGui.Picker.Background.RoleGiven.Text = "Innocent"
plr.PlayerGui.Picker.Background.othertext.Text = "You Are"
plr.PlayerGui.Picker.Background.RoleGiven.TextColor3 = Color3.fromRGB(0, 255, 0)
plr.PlayerGui.Picker.Background.Visible = true
workspace.numofinnocents.Value = #survivors
if #survivors == 1 then
workspace.Innocentnames.innocentA.Value = (survivors[1])
elseif #survivors == 2 then
workspace.Innocentnames.innocentA.Value = (survivors[1])
workspace.Innocentnames.innocentB.Value = (survivors[2])
elseif #survivors == 3 then
workspace.Innocentnames.innocentA.Value = (survivors[1])
workspace.Innocentnames.innocentB.Value = (survivors[2])
workspace.Innocentnames.innocentC.Value = (survivors[3])
elseif #survivors == 4 then
workspace.Innocentnames.innocentA.Value = (survivors[1])
workspace.Innocentnames.innocentB.Value = (survivors[2])
workspace.Innocentnames.innocentC.Value = (survivors[3])
workspace.Innocentnames.innocentD.Value = (survivors[4])
elseif #survivors == 5 then
workspace.Innocentnames.innocentA.Value = (survivors[1])
workspace.Innocentnames.innocentB.Value = (survivors[2])
workspace.Innocentnames.innocentC.Value = (survivors[3])
workspace.Innocentnames.innocentD.Value = (survivors[4])
workspace.Innocentnames.innocentE.Value = (survivors[5])
end
end
end
end
end
