Every 0.25 seconds (by default) the table gets looped through to check if any part in that table is below the destroy height.
A part is unsupported (thus won’t be in the table) if it’s either:
Anchored (unless DestroyAnchoredParts is enabled in settings)
Has one of the exclusion tags in settings
Due to necessary optimizations, unsupported parts that become supported won’t reappear in the table (e.g. unanchoring an anchored part)
To fix this, you need to manually call DestroyHeight.MonitorPart(Part) in another script (otherwise it’ll fall forever and cause a memory leak!)
Available settings include:
Height at which the parts destroy at
Delay between each height check (Lower delay increases lag)
A table of tags to exclude. A part with at least one of the tags from the table won’t be destroyed if it’s below the destroy height (This is why this module exists in the first place)
Whether to destroy non-character ancestors of monitored parts that are direct CHILDREN of Workspace (Do you sort your Workspace by models? Then turn this on)
Whether to also destroy anchored parts or not (Huge toll on performance, not recommended at all. Someone might need this though)
Debugging but like who cares
You can tweak the destroy logic inside the DestroyHeight module itself and I even left a little example there of what custom stuff you can do.
I’m surprised something like this hasn’t been made before. I honestly had a lot of fun coding this as well
I figured that it’d be more efficient to make my own parts table and update its contents by using workspace.DescendantAdded and DescendantRemoving, and not just loop through the entire workspace each heartbeat.
If your question is more about… my code just being bad, then take a look at this answer to a thread asking about GetPropertyChangedSignal(“Position”) not working. Unfortunately, it seems like there’s no better way to do this.
Fixed a lot of bugs, memory leaks, etc. (I’m kind of ashamed that I released DestroyHeight at such a raw state honestly)
Removed option to fully destroy humanoid models as you wouldn’t be able to respawn if it’s turned on
Added a delay option that delays the height check loop
(Suggested by @UniDevx)
Added an option to not destroy non-humanoid ancestors of monitored parts that are direct children of Workspace (For anyone who sorts their Workspace by models like me)
A part will now be supported if its root part doesn’t equal to itself (made this change because when a player uses a seat the hrp assemblyrootpart changes)
My game had a problem where I didn’t want specific parts to get sucked up by the void, so I made this module to include an “exception tag” setting that wouldn’t destroy a part if it has a specific tag and lots of other settings for people that might need them.
If you’d read the post carefully, I already made a remark on the exception tags being the reason why this module exists in the first place