This property determines the order in which a
GuiObject|GUI renders to the screen relative to other GUIs.
By default, GUIs render in ascending priority order where lower values are rendered first. As a result, GUIs with lower ZIndex values appear under higher values. You can change the render order by changing the value of
The range of valid values is -MAX_INT to MAX_INT, inclusive (2,147,483,647 or (2^31 - 1)). If you are unsure if you will need to layer an element between two already-existing elements in the future, it can be a good idea to use multiples of 100, i.e. 0, 100, 200. This ensures a large gap of ZIndex values you can use for elements rendered in-between other elements.
GuiObject/LayoutOrder, which controls the sort order of a GUI when used with a
UIGridStyleLayoutinstead of render order.
This code sample flips the ZIndex rendering order of two frames.
-- Place this in a LocalScript that is a sibling of -- two GuiObjects called "FrameA" and "FrameB" local gui = script.Parent local frameA = gui:WaitForChild("FrameA") local frameB = gui:WaitForChild("FrameB") while true do -- A < B, so A a renders first (on bottom) frameA.ZIndex = 1 frameB.ZIndex = 2 wait(1) -- A > B, so A renders second (on top) frameA.ZIndex = 2 frameB.ZIndex = 1 wait(1) end