Need help with taking data from tables?
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:
01 | local plrs = game.Players |
05 | local alreadypicked = false |
10 | if alreadypicked = = false then |
12 | local chosen = plrs:GetChildren() [ math.random( 1 , #plrs:GetChildren()) ] |
14 | chosen.PlayerGui.Picker.Background.RoleGiven.Text = "Murderer" |
15 | chosen.PlayerGui.Picker.Background.othertext.Text = "You Are The" |
16 | chosen.PlayerGui.Picker.Background.RoleGiven.TextColor 3 = Color 3. fromRGB( 255 , 0 , 0 ) |
20 | game.Workspace.murderername.Value = chosen.Name |
22 | chosen.PlayerGui.Picker.Background.Visible = true |
24 | for i, plr in pairs (plrs:GetChildren()) do |
28 | table.insert(survivors, plr) |
30 | plr.PlayerGui.Picker.Background.RoleGiven.Text = "Innocent" |
31 | plr.PlayerGui.Picker.Background.othertext.Text = "You Are" |
32 | plr.PlayerGui.Picker.Background.RoleGiven.TextColor 3 = Color 3. fromRGB( 0 , 255 , 0 ) |
34 | plr.PlayerGui.Picker.Background.Visible = true |
36 | workspace.numofinnocents.Value = #survivors |
40 | if #survivors = = 1 then |
41 | workspace.Innocentnames.innocentA.Value = (survivors [ 1 ] ) |
42 | elseif #survivors = = 2 then |
43 | workspace.Innocentnames.innocentA.Value = (survivors [ 1 ] ) |
44 | workspace.Innocentnames.innocentB.Value = (survivors [ 2 ] ) |
45 | elseif #survivors = = 3 then |
46 | workspace.Innocentnames.innocentA.Value = (survivors [ 1 ] ) |
47 | workspace.Innocentnames.innocentB.Value = (survivors [ 2 ] ) |
48 | workspace.Innocentnames.innocentC.Value = (survivors [ 3 ] ) |
49 | elseif #survivors = = 4 then |
50 | workspace.Innocentnames.innocentA.Value = (survivors [ 1 ] ) |
51 | workspace.Innocentnames.innocentB.Value = (survivors [ 2 ] ) |
52 | workspace.Innocentnames.innocentC.Value = (survivors [ 3 ] ) |
53 | workspace.Innocentnames.innocentD.Value = (survivors [ 4 ] ) |
54 | elseif #survivors = = 5 then |
55 | workspace.Innocentnames.innocentA.Value = (survivors [ 1 ] ) |
56 | workspace.Innocentnames.innocentB.Value = (survivors [ 2 ] ) |
57 | workspace.Innocentnames.innocentC.Value = (survivors [ 3 ] ) |
58 | workspace.Innocentnames.innocentD.Value = (survivors [ 4 ] ) |
59 | workspace.Innocentnames.innocentE.Value = (survivors [ 5 ] ) |