I just started re-writing my topbar module, and im running into a problem. Instead of chat offsets, I am doing left and right frames to make the UX much better. But its honestly hard to get the button because I have no idea which side it is on. Now you could just say, just iterate over both frames! But this is very hard and just insecure. I have a code snippet where I tried to iterate:
local StateInteraction = {}
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local CurrentState = "Default"
repeat task.wait() until Player
local Topbar = Player:WaitForChild("PlayerGui"):WaitForChild("Topar"):WaitForChild("TopbarFrame")
function StateInteraction:HoverIcon(icon : string)
for index, value in pairs(Topbar:WaitForChild("TopbarFrame"):GetDescendants()) do
if value.Name ~= "LeftFrame" and value.Name ~= "RightFrame" and value.Name ~= "Layout" and value.Name == icon then
local StateOverlay = value:FindFirstChild("Background"):WaitForChild("StateOverlay")
local ButtonStateValue = value:FindFirstChild("Background")
StateOverlay.ImageTransparency = 0.9
StateOverlay.ImageColor3 = Color3.fromRGB(255,255,255)
CurrentState = "Hovering"
ButtonStateValue.Value = "Hovering"
end
end
end
return StateInteraction
Its honestly a mess and I really want an easier to get the icon.