How Would I Add A Topbar Button?

I have a emote gui button but it looks out of place with my other guis, so I was wondering is there anyway I could make my own custom topbar button, for example the hd admin topbar button.

11 Likes

You can’t add a button to the top bar, but if you want to mimic it being in the top bar then you can set the transparency of the top bar to 1 and create a frame in place of it.
Top bar size is (1,0,0,36)
More info on creating a custom topbar here.

5 Likes

No worries, my top bar button has been long gone, but i will use this code for future top bar buttons, thanks for your help.

3 Likes

Why does this use a while loop? Can it be done without? I am concerned as it is usually both more costly and less than optimal to do so.

The player as in the developer or the player as in the actual gamer? I don’t ever recall the latter being a thing, the greatest change being highlighting the backpack ect. to open up the associated ui. If you can explain the additional stuff it would help, thanks!

Do you mean something like this? (Button on the top bar?)

5 Likes

Depends, if this is a toolbox item, or you call SetCoreGui with a delay, or you can enable core gui in your game, this can update the core UI positioning without it glitching. If the wild loop is bad performance then you can add delay, but I don’t want to.

Ah, thank you, yes I figure if I wanted to be superfluous we could try to hook it up to a changed event of the bar (provided it exists). Thank you for clarifying, I think it will do and hopefully I kept this in the interests of OP as well.

1 Like

that is what i was going for when i made this post one year ago

thanks for your help, on this old topic,although i don’t have a use for the button atm, i will use this in the future if a make a custom admin for example.

I made a model for the new topbar , here it is :

https://www.roblox.com/library/5027956905/CustomTopBarButtons

the usage is pretty simple , in the “Main” local script do :

local NewButton = CreateButton(Image Id,Name,Icon Size)

NewButton:Connect(function()
-- your code that gets executed when the button is clicked
end)

Edit : the default size is UDim2.new(0,24,0,24) but you don’t need to change that , just leave it blank and it’ll stay the default size.

9 Likes

There’s a new module that lets you do this really easily: Topbar+ v1 (deprecated) | Add additional functionality and themes to your topbar

6 Likes

You could make it rely on BindableEvents (or RemoteEvents if it’s the server communicating) though instead of using a while-loop. Seems pointless to me, to be honest.

2 Likes

I understand I made this script a long time ago when I didn’t know about performance and what it can do to your game. Thanks for pointing this out though.

2 Likes