DestroyHeight v1.2 | Flexible FallenPartsDestroyHeight

Did you know that the FallenPartsDestroyHeight property of Workspace kind of sucks and is barely customizable?

And because of that, I’ve made this beautiful module:


DestroyHeight v1.2

destroyHeight

Get the module here


What is DestroyHeight?

DestroyHeight is an alternate way of handling fallen parts with lots of customization.

The only two main differences are:

  1. It now uses the :Destroy() method to remove parts, and not just sets their parent to nil (This is a bit useful for garbage collection)
  2. There is a bit of delay between each height check (You can lower it in settings, but then DestroyHeight will cause more lag)

How to use:

  1. Make sure you’ve disabled FallenPartsDestroyHeight by running this in the console: workspace.FallenPartsDestroyHeight = 0/0
  2. Require the module and call the initialize function in a server script

What you can customize:

  • Height at which the parts destroy at

  • The destroy logic (What happens to a part when it’s below the destroy height)

  • 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 initially why I even wanted to make this module!)

  • Whether to destroy non-humanoid 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 (Can take a huge toll on performance, not like anyone is gonna use this though)

  • All options above are able to be changed in other scripts! (…I’m not sure if that’s unique enough to list here)

All of these options are set to behave as close as possible to FallenPartsDestroyHeight by default

Important note:

If a part becomes unanchored while initially being anchored, you will have to call DestroyHeight.MonitorPart() on said part, otherwise it’ll fall forever!


I’m surprised something like this hasn’t been made before. I honestly had a lot of fun coding this as well

Feedback and suggestions appreciated!

3 Likes

I really am curious if this is a performant way to do it.
image

1 Like

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.

1 Like

The least you can do is throttle execution little bit, you don’t really need to check all of parts each every frame.

2 Likes

Good idea. I’ll implement this hopefully tomorrow as it’s late right now for me

I think you can disable this officially using workspace.FallHeightEnabled now

It doesn’t actually do anything right now

DestroyHeight v1.1 Changelog:

  • 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)
  • Added a debug option

DestroyHeight v1.2 Changelog:

  • Removed leftover unused code
  • Optimized the isSupportedPart and isSupportedAncestor functions a bit by putting a guard clause
  • When a player is found, now it checks if the part is the character’s primary part instead of checking if the name is “HumanoidRootPart”
  • Parts table and the DestroyLogic function can now be accessed by other scripts
  • Removed the empty task.wait() in the parts table loop