How do I add buttons to the topbar?

I want to add custom buttons to the topbar, like the buttons on HD Admin on the top of the screen. Is it possible without using Topbar+. I tried using Topbar+ but it did not work and does not show up. If you still want me to use Topbar+, can anyone make a fix for it?

This is my code for the Topbar+ in StarterPlayerScripts

local frame = game.Players.LocalPlayer.PlayerGui.MAINGUIs
local Icon = require(game:GetService("ReplicatedStorage").Icon)
local icon = Icon.new()
icon:setImage("rbxassetid://3926305904")
icon:notify()
icon.deselected:Connect(function()
	frame.InfoFrame.Visible = false
end)
icon.selected:Connect(function()
	frame.InfoFrame.Visible = true
end)

I tried to do everything. I looked at the API, tutorials (no one made any for Topbar+ and they are the old topbar with the hamburger icon.)

Edit: I did look at the playground but when I try to use the code in the playground, it still wont work sadly. I have the Icon script in ReplicatedStorage.

2 Likes

Coudln’t you just set the frames position to something like:

Udim2.new(0.3,0,-0.05,0)

Yes however it would not work with my game due to how much GUIs are in place. I forgot to mention that. I will try this but its not likely though.

That’s how I have always done it, if it doesn’t work could you send a screen shot of what happens so we can find a solution.

Your icon constructor code looks fine, it’s likely to do with the first line:

local frame = game.Players.LocalPlayer.PlayerGui.MAINGUIs

Double check you’re referencing this correctly then try this instead:

local frame = game.Players.LocalPlayer.PlayerGui:WaitForChild("MAINGUIs")

If any issues persist can you provide any errors that appear in the console?

Also feel free to ask for help within the main TopbarPlus thread as we don’t always see help requests outside of that and the github repo.

4 Likes