How to make a UI element stay on the top bar

I’m unsure how to keep an icon on the top bar segment of my screen.
I’ve tried using scale and offset values but in the way I’ve made makes it to stay where it should be on certain resolutions.
Does anyone have any different ways to get around this?

2 Likes

This topic should help a lot.

2 Likes

Thanks, I’ll have a go shortly.

ScreenGui.IgnoreGuiInset = true ?

2 Likes

Those buttons in the top bar have a fixed size, their size are UDim2.new(0,50,0,36). So if you make your own custom button, just make sure its size is UDim2.new(0,50,0,36).
As there are 3 buttons in the topbar by default, you have to change the position of your button to UDim2.new(0,150,0,0).

Also, you have to set ScreenGui.IgnoreGuiInset = true, else the button will not appear inside the topbar.

Conclusion:
Button Position: UDim2.new(0,150,0,0)
Button Size: UDim2.new(0,50,0,36)
ScreenGui.IgnoreGuiInset = true

9 Likes

What’s the X.Offset increment for the buttons?

1 Like

Use the negative Y value of this to position the icon and make the icon sized accordingly. The Inset differs on platforms so I’d recommend using scripts to reposition the icon.

Alternatively, please see : ScreenGui | Documentation - Roblox Creator Hub

1 Like