Making GUI appear on top of other GUI

image image

In my game, I have an ImageLabel (the white square) with a TextLabel inside of it (the 1x)

You can see how the 1x is appearing behind a separate ImageLabel to its right, and my question is, how can I fix this?

Changing the ZIndex of the TextLabel hasn’t fixed it, and both the ImageLabels have the same ZIndex

Change the ZIndex of the ImageLabel, not the TextLabel

I’ve tried, and that works. But, each ImageLabel represents an object in a player’s inventory, meaning ImageLabels will need to be frequently added and removed

Is there no way to make the TextLabel automatically appear on top of any ImageLabel without having to use a script to manually find what the ZIndex should be each time?

The problem of setting ui elements and parenting is that if let’s say you have a frame and a textlabel in it you duplicate that frame, the problem here is that the cloned Frame with the TextLabel will “win the Z-Fighting” and the cloned frame will be overwriting the original frame. The only real solution (in what I found to not set the Z-Index) is to parent the frame somewhere else and the parent it back, but this gets annoying too. So my best advice to just space out the item frames a bit further away so that “1x” is not under the imagelabel.

Maybe someone else can help with that problem but this is the best solution i got

Ok, thanks for the info. I’ll give it a little bit, and if I can’t find a better answer or nobody else replies with a better answer, I’ll mark this as a solution for now :+1:

image

I found a way, even though its not perfect, but it’s good enough for now. I moved the icons into a new ScreenGui and set the new ScreenGui’s “ZIndexBehavior” property to global, so each TextLabel has its own independent ZIndex that isn’t influenced its parent’s ZIndex

I do think this should be a property of all gui objects, so you can change how ZIndex works for anything inside of specific gui objects, but unfortunately it’s not a thing for all gui objects

1 Like

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