Allow negative ZIndexes

I know ZIndex goes up to +2B, but I have a lot of GUI elements in a game, and I want to be able to render a GUI under all others if possible. Problem is that a lot of ZIndexes of GUIs are set to 1. 1 is the default. I don’t want to go through the hassle of changing all ZIndexes or having to run code in the command bar just to layer this particular GUI underneath.

Of course, I could go on changing like 40 or 50 ZIndexes, and what happens if I had to make a GUI that renders underneath that particular GUI? I’d have to do it again. Letting ZIndex go at 0 or -1 or even under that (-2B) would be nice.

16 Likes

An integer is any numeral not including decimals, we already have these “Integer ZIndexes”.

3 Likes

ZIndex has to be >= 0. Integers can be smaller than 0, ZIndex cannot.


This feature request might become more clear if its title is changed to “Allow Negative ZIndexes”

2 Likes

This is why I make my default zindex 100

1 Like

I like it, but it should go into Client Features, since you’re suggesting something that affects the entirety of client+studio.

1 Like

As a temporary fix you can always run a quick command in the command bar using GetDescendants which raises every ZIndex by some amount. Real simple and will take under a minute rather than going through every gui object you have and changing it manually.

3 Likes

You can make a ScreenGui with a lower DisplayOrder.

When ZIndexBehavior.Sibling is enabled, we’ll need negative ZIndex values to avoid having to awkwardly restructure our UI hierarchy. For example, I want an image border behind a button: Ideally I would create the image, parent it to the button, and then set its ZIndex to -1 so it would layer under the button even though ZIndexBehavior.Sibling is enabled.

With ZIndex values constrained to > 0, I would have to parent the button to its own border so all code becomes root.border.button instead of root.button – this is unwanted because logically a border is an attribute of a button (it doesn’t make sense the other way around), and it bloats the references to the button instance.

5 Likes

Ok, so putting things behind their parent. Sounds reasonable.

yes

While we’re at it, is there any reason why ZIndex can’t be changed to a float?


This a totally different feature, and conflicts with the OP. Changing the order in relation to the parent when the ZIndex goes negative would be counterproductive to solving the posed problem. OP basically wants the ZIndex to default to the middle of the ZIndex space, rather than the bottom.

Your request would work better as a new ZIndexBehavior, one which causes the parent to be involved in the ordering. It wouldn’t make sense with Sibling, since the parent is not a sibling.

2 Likes

Setting a negative ZIndex would not help you in this case, unfortunately. Sibling doesn’t work like that. You may be thinking of the way CSS does it, which is where each node has a Z depth based on its depth in the hierarchy, and then the ZIndex property is a relative offset to that value. I just put the button inside its border, generally.

1 Like

ZIndex clamping is now disabled on production. Negative ZIndexes are allowed. You can now use them to force an element to render underneath its siblings, for example. It will not allow you to render an element beneath its parent in Sibling mode, though.

12 Likes

Why can’t an element be rendered beneath it’s parent when ZIndex is set to < 0?? It makes this feature a lot less useful imo

1 Like

The way that the Sibling mode works is that the ZIndex property controls the ordering relative to its siblings, not relative to some kind of global value. It wouldn’t really make sense with how its behavior is defined for it to work like you’re describing.

One advantage of this approach is that if you have two objects with children, and they are overlapping, one will render over top of the other’s children. This makes it so that you don’t get the “interlocked fingers” visual of the children rendering over top of both parents, instead of only over top of one.

Sorry to bump a post that’s a couple months old, but there should be a way to put a sibling behind its parent. I’m currently having to restructure my UIs just to put a background behind my ViewportFrames.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.