We use cookies on this site to enhance your user experience
Collapse Sidebar




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 ScreenGui.ZIndexBehavior.

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.

See also

  • GuiObject/LayoutOrder, which controls the sort order of a GUI when used with a UIGridStyleLayout instead of render order.

Code Samples

ZIndex Alternate

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
	-- A > B, so A renders second (on top)
	frameA.ZIndex = 2
	frameB.ZIndex = 1