I have been trying to figure out why it won’t let me click more than 2 buttons. When I click 2 it works fine but if I click another 2 or the same ones again NOTHING happens. It is really starting to annoy me as I have been working on it since last night and I really just don’t understand the issue. Please help me.
local TopBar = {}
local players = game:GetService('Players')
local player = players.LocalPlayer
local playergui = player.PlayerGui
local function buttons_(buttonName)
local frames = playergui:WaitForChild('MainUI'):WaitForChild('Frames')
for _, child in pairs(frames:GetChildren()) do
if child:IsA("GuiObject") then
child.Visible = false
end
end
if buttonName == 'profile' then
frames:WaitForChild('ProfileHolder').Visible = true
end
if buttonName == 'currency' then
frames:WaitForChild('ConversionHolder').Visible = true
end
if buttonName == 'settings' then
frames:WaitForChild('SettingsHolder').Visible = true
end
if buttonName == 'upgrades' then
frames:WaitForChild('UpgradesHolder').Visible = true
end
end
function TopBar.init(MainFrame)
print('init')
local ButtonsFolder = MainFrame:WaitForChild('Others')
local HolderFrame = ButtonsFolder:WaitForChild('Holder')
local MainHolder = HolderFrame:WaitForChild('Main')
local buttons = {
profile = MainHolder:WaitForChild('Profile'),
currency = MainHolder:WaitForChild('Currency'),
settings = MainHolder:WaitForChild('Settings'),
upgrades = MainHolder:WaitForChild('Upgrades')
}
local hoverTemplate = script:FindFirstChild('Hover')
local clickTemplate = script:FindFirstChild('Click')
if not hoverTemplate or not clickTemplate then
return
end
for n, butn in pairs(buttons) do
butn.MouseEnter:Connect(function()
local hoverSFX = hoverTemplate:Clone()
hoverSFX.Name = 'hover'
hoverSFX.Parent = butn
hoverSFX:Play()
end)
butn.MouseLeave:Connect(function()
if butn:FindFirstChild('hover') then
butn:FindFirstChild('hover'):Stop()
butn:FindFirstChild('hover'):Destroy()
elseif butn:FindFirstChild('p') then
butn:FindFirstChild('p'):Stop()
butn:FindFirstChild('p'):Destroy()
end
end)
butn.MouseButton1Click:Connect(function()
local purchaseSFX = clickTemplate:Clone()
purchaseSFX.Name = 'p'
purchaseSFX.Parent = game:GetService("SoundService")
purchaseSFX:Play()
game.Debris:AddItem(purchaseSFX, 2)
buttons_(n)
end)
end
end
return TopBar
-- local script
local Players = game:GetService('Players')
local TS = game:GetService('TweenService')
local RS = game:GetService('ReplicatedStorage')
local Modules = RS:WaitForChild('Modules')
local UIFolder = Modules:WaitForChild('UI')
local TopBarModule = require(UIFolder:WaitForChild('TopBarModule'))
local mainFrame = script.Parent
TopBarModule.init(mainFrame)
Thank you


