Hi . I am wondering how does roblox render gui elements . I am intrested in the order eg) Higher ZIndex comes first . However, when 2 gui objects have the same ZIndex, which gui would overlap the other?? Thank you in advance
i think the parent would overlap the child
but if the gui elements are not parents or children of the other one, i believe they’ll just fight and constantly overlap themselves (something you see in parts when they’re in the same position, they fight and constantly overlap)
hmm i know that Z-fighting appears in 3d objects, however, in gui objects, I have notice that their order are usually constant, is there a way to figure out which comes on top?
If two UI elements have the same ZIndex, it’s just whatever element was created most recently that takes priority. Studio seems to save this priority so that it won’t change when the game is actually ran.
is it possibke to see which GUI Element is created the most recent???
I don’t think so unless you keep track of their time of creation manually. Honestly it’s just easier to separate their ZIndex if you actually care about this though. That’s all there really is to it
aw that is kinda sad … I am trying to get the highest gui object at my mouse cursor but currently, i think it is close to impossible
breakthrough. I notice that :GetChildren()
returns the children of an object in an order where the newly created Instance comes first
Yeah that should work
Also this might work for what you want
local Player = game:GetService("Players").LocalPlayer
local playergui = Player.PlayerGui
local mouse = Player:GetMouse()
mouse.Button1Up:Connect(function()
local uis = playergui:GetGuiObjectsAtPosition(mouse.X, mouse.Y)
local top_ui = uis[1]
print(top_ui, uis)
end)
hmm intresting , let me try it out. I will give you the solution for the post above . Thank you for your help
Np
Also the code I sent is for all uis. If you want to only do it for certain uis then you should be on the right path with :GetChildren()
and yes this code works thank you for saving me another hour+ of coding xD