01 | local Rolelist = { |
02 | [ "Mafia" ] = 1 , |
03 | [ "Doctor" ] = 2 , |
04 | [ "Jailor" ] = 3 |
05 | } |
06 | local Role = Instance.new( "IntValue" , plr) |
07 | Role.Name = "Role" |
08 | Role.Value = 0 |
09 | local function random 2 () |
10 | local number = math.random( 1 , #Rolelist) |
11 |
12 | repeat |
13 | number = math.random( 1 , #Rolelist) |
14 | until ( not roleUsed [ number ] ) |
15 |
What am I doing wrong?
I don't believe you've provided the full script; so I don't know where the line 19 quoted in the title is.
I hope maybe by rewriting this section I can help others understand this more.
01 | local RoleUsed = { } |
02 | local RoleList = { } |
03 |
04 | RoleList [ "Mafia" ] = 1 |
05 | RoleList [ "Doctor" ] = 2 |
06 | RoleList [ "Jailer" ] = 3 |
07 |
08 | local IntValue = Instance.new( "IntValue" ) |
09 | IntValue.Name = "Role" |
10 | IntValue.Value = 0 |
11 | IntValue.Parent = plr |
12 |
13 | local function random 2 () |
14 | local n = math.random( 1 , #RoleList) |
15 | repeat |
This is the full script
01 | local used = { } |
02 | local roleUsed = { } |
03 |
04 | local Rolelist = { |
05 | [ "Mafia" ] = 1 , |
06 | [ "Doctor" ] = 2 , |
07 | [ "Jailor" ] = 3 |
08 | } |
09 | game.Players.PlayerAdded:Connect( function (plr) |
10 |
11 | local Id = Instance.new( "IntValue" , plr) |
12 | Id.Name = "Id" |
13 | Id.Value = 0 |
14 |
15 | local Role = Instance.new( "IntValue" , plr) |