I have this function. but I need help with the table.remove()
part. It keeps saying:
14:51:45.155 - Workspace.Script:8: bad argument #2 to 'remove' (number expected, got string)
local items = {"Innocent","Innocent","Sheriff","Murderer"} function Choose() for i = 1,#items do local Player1 = items[math.random(#items)] local Display = Instance.new("Hint",game.Workspace) Display.Text = "You are: "..Player1 table.remove(items, Player1) --I need help removing whatever Player1 picks from items. end end Choose()
Remember which one you picked
It's helpful sometimes just to take things one step at a time, particularly if you need to remember some important details.
local items = {"Innocent","Innocent","Sheriff","Murderer"} function Choose() for i = 1,#items do local n = math.random(#items) local Player1 = items[n] local Display = Instance.new("Hint",game.Workspace) Display.Text = "You are: "..Player1 table.remove(items, n) -- Remove the chosen entry. end end Choose()
I don't think your code will work how you want it to, despite the change I've made. That's your issue.