Using table.remove doesnt work

i created a script where when a player touch the first part he get introduced into the table
but when he touchs the second part he is supposed to be removed from the table but using table.remove gives me this error in the output : invalid argument #2 to 'remove' (number expected, got string)

PartRouge.Touched:Connect(function(Hit1)



	local Player1 = game.Players:GetPlayerFromCharacter(Hit1.Parent)

PartBleu.Touched:Connect(function(Hit2)

	local Player2 = game.Players:GetPlayerFromCharacter(Hit2.Parent)


	if Player2.Name == Player1.Name then
		table.remove(EquipeRougeTable, Player1.Name)	
	end
end)
end)

the second parameter of table.remove should be the index of the object in the table that you want to remove thats why the error says “number expected got string”

For example

table = {a, b, c}
table.remove(table, 2)
print(table)
-- will print {a, c}
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.