local Rolelist = {
["Mafia"] = 1,
["Doctor"] = 2,
["Jailor"] = 3
}
local Role = Instance.new("IntValue", plr)
Role.Name = "Role"
Role.Value = 0
local function random2()
local number = math.random(1, #Rolelist)
repeat
number = math.random(1, #Rolelist)
until (not roleUsed[number])
roleUsed[number] = true
Rolelist.Value = number
end
random2()
What am I doing wrong?

4 comments
can you put your full script or a little more? line 19 is blank from what you sent
try printing RoleList right before line 19, see what is inside of it.
maybe the table is supposed to be something like local Rolelist = {'Mafia', 'Doctor', 'Jailor'} (without the = Number)
After testing it, for some reason its counting Rolelist as having zero entries. Maybe cause its a dictionary and not an array, but I don't remember that sort of behaviour being a thing.