Perhaps you are getting a collision in your table keys? Or mixing numerical and non-numerical keys in a table where you use table.insert or #table?
I’ve found that I tend to use two types of tables for data (like display objects).
Type 1:
t = {}
t[1] = a
t[2] = b
for i=#t, 10000 do
t[i] = x
end
Everything in this table is inserted numerically, and I can add/subtract elements without ever creating holes. No holes means I can use #t all day long to find the next place I want to insert some data.
Type 2:
t = {}
t.var = 256
t.newkey = “data”
In this table, I have a bunch of keys, like player profile data or a Class Object. Some keys might be nil. The point is that every key is a string, which I need to look up specifically when calling that data back.
If you ever mix numerical and non-numerical keys in a table, you can start to run into serious issues. For example, display groups can hold lots of display objects which you reference by name, but which are stored numerically. Mixing types also makes #t unreliable, and pretty much eliminates any useful function of table.insert or table.sort
My gut reaction to your problem is to suspect that you are mixing up your table keys, which is leaving gaps in a table somewhere which you expect to have no gaps - or clobbering some key with some wrong type of data, which has the same effect.
All of this is a long way of saying - you probably shouldn’t be working directly with display group insertions. Have your objects return a handle, and store those handles in a number-key tables. If you set that up properly, display group insertions / removals should handle themselves. [import]uid: 65996 topic_id: 15495 reply_id: 57294[/import]