TopbarPlus help

Does anyone know how to make the dropdown buttons get detected when the button is clicked?

Here is my code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Icon = require(ReplicatedStorage.Icon)
local IconController = require(ReplicatedStorage.Icon.IconController)

local icon = Icon.new()

IconController.voiceChatEnabled = true
icon:setLabel("Shop")
icon:setImage("rbxassetid://15578030072")
icon:setDropdown({
	Icon.new():setLabel("Gold"):setCornerRadius(0, 0):setImage("rbxassetid://15578233381");
	Icon.new():setLabel("Diamond"):setCornerRadius(0, 0):setImage("rbxassetid://15578359865");
})
2 Likes

I just checked the api and found it pretty quickly:

local Icon = Icon.new()

Icon.userToggled:Connect(function ()
	--your code
end)

I know this way, it detects when the main button is clicked (the shop button). What I want is to detect when the drop-down menu buttons are clicked, like gold and diamond.

1 Like

Well then i’d just move the new buttons up in scope and make the toggled reference elsewhere:

local icon = Icon.new()
IconController.voiceChatEnabled = true
icon:setLabel("Shop")
icon:setImage("rbxassetid://15578030072")

local GoldIcon = Icon.new()
GoldIcon:setLabel("Gold"):setCornerRadius(0, 0):setImage("rbxassetid://15578233381")

local DiamondIcon = Icon.new()
DiamondIcon:setLabel("Diamond"):setCornerRadius(0, 0):setImage("rbxassetid://15578359865")

icon:setDropdown({
	GoldIcon;
	DiamondIcon;
})

GoldIcon.userToggled:Connect(function ()
    --Gold icon toggle
end)

DiamondIcon.userToggled:Connect(function()
    --Diamond icon toggle
end)
1 Like

This works, thank you so much.

Hello, by the way, do you know how I can add an image to the left of the text?

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