How do I make table.Count() decrease?

Hi, I’m currently trying to setpos entities in a circle based on how many there are.

I’m doing: for I=1,table.Count(Table) do (stuff) end

It works when the amount of entities increases but does not when the amount decreases, and the code runs the same way as if there were still more entities than there are.

I would appreciate any help that gets thrown my way, thanks.

how are you removing entities inside Table

I am removing them by deleting the props/entities in the world.

When an entity is deleted, it just becomes NULL, for a value to be removed from a table, it has to become nil.

So how would I make it so that when I remove a prop/entity in the world, the count of how many there are decreases then?

Depends on how you’re removing and how it’s indexed inside the table, general purpose way of doing it would be

GM:EntityRemoved I suppose.

Thanks, I eventually got it figured out in the end.

Although be warned that EntityRemoved is called for every entity clientside before/during a full update, if you’re doing this on the client.