New ZIndexBehavior property is now live

ZIndexBehavior is a new property on LayerCollector objects (ScreenGui, BillboardGui, SurfaceGui) that changes the way the ZIndex property behaves for all GuiObjects contained inside. For now, it has two options:

  • Default: The previous behavior before this change, where objects were sorted first by ZIndex, then secondly by their hierarchy ordering.

https://devforum.roblox.com/uploads/default/original/3X/b/d/bd6d0ad5fa8cf3c65b66d5c1a4f40b5376637c70.jpg

  • Sibling: A new behavior, which we hope will be more intuitive and useful to developers. In this scheme, objects are sorted first by their (depth first) hierarchy ordering and secondly by their ZIndex. This means that settings the ZIndex only rearranges how GuiObjects render relative to their siblings. You also don’t need to recursively apply ZIndex anymore. If the parent has a ZIndex of 10, the children do not need to be updated to 10 in order to still render on top.

https://devforum.roblox.com/uploads/default/original/3X/2/7/27bb2cfb60583048e9266377107626a7e170b36a.jpg

(diagrams credit to @Maximum_ADHD)

What do you think the default should be when inserting a new object through Studio? (This would not apply to serialization or Instance.new because of backwards compatibility.)

  • Default
  • Sibling
  • I want a different behavior
  • Don’t care

0 voters

40 Likes

This is everything I’ve ever wanted.

Sibling should be the default absolutely as this is the more common use case and will be easier for beginners. (And nobody panic, changing the inserted studio default doesn’t change your already-created guis)

12 Likes

With sibling, is there any chance ZIndex constraints could be changed to allow negative values?

22 Likes

This brought me back to the time when I first cracked open GUI objects and I thought this was how ZIndex worked initially. Good change. Also thanks to Clone for the picture - it’s worth a thousand words.

(How about SizeFromContents next? :smiley: )

6 Likes

This is going to be unbelievably useful starting immediately

tyyyy <3

1 Like

Which mad man asked for a different behaviour?

unless that behaviour is negative z indexes, in which case yes plz

Just in case you guys couldn’t tell from the picture alone:

Number = ZIndex
Arrow = ‘Parent → Child’ relation

Default is better, but only because there aren’t negative ZIndexes.

4 Likes