Add a way to get absolute/global Z Index

As a Roblox developer, it is currently too hard to determine which UI element displays on top of another with the “Sibling” ZIndexBehavior.

I prefer using the “Sibling” ZIndexBehavior because it makes it easier to manage how different menus interact when occupying the same space, but it makes it significantly harder to programatically determine when certain elements display on top of another. With “Global” behavior it’s as easy as finding the one with the higher ZIndex, but “Sibling” behavior requires checking every ancestor with a ZIndex property and comparing it with all the ancestors of the other element. The process for both sibling and global behaviors gets more complicated when taking into account the DisplayOrders of the ScreenGuis if the two UI elements are in separate containers.

Some sort of API for easily getting the absolute ZIndex of a UI element relative to other elements would be awesome.

Here are some use cases:

  • A tooltip system where tools can be covered up by pop-up menus depending on screen size
  • A constantly updating UI element with expensive calculations that can stop updating when not visible to improve performance
  • Any element with some kind of hovering behavior that shouldn’t run if it’s being covered up
10 Likes

In the meantime, I’ve found a way to get the display order of elements at a certain position! GetGuiObjectsAtPosition returns elements in order of appearance, not just ZIndex, so you can always grab the top object by referencing the first object in the table. It would still be nice to have a dedicated API but it works fantastically for my purposes and solves pretty much all of the use cases I gave above.

5 Likes

Thank you!
I’ve been looking for this type of solution for quite some time - till I found your thread, this help a lot! :innocent: