Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with a chooser script. [?]

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()

1 comment

1

Remember to tab your code..

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.