My goal is to listen for Activated event inside an array of buttons. That way, Im able to insert as many buttons as I want and by using only one script listen if they are clicked. For now, script below checks for TextButtons in every TextLabel inside StatusGUI, and adds them to Buttons table
My Code so far - LocalScript (named InvestPoints)
local StatsGUI = script.Parent
local Buttons = {}
for i, v in StatsGUI:GetChildren() do
if v:IsA('TextLabel') then
local vChild = v:GetChildren()
for btn, _ in vChild do
if vChild[btn] ~= nil and vChild[btn]:IsA('TextButton') then
local vButton = vChild[btn]
vButton:SetAttribute('Upgrade', v.Name)
Buttons[vButton.Name] = vButton:GetAttribute('Upgrade')
print(Buttons)
end
end
end
end
Saw some methods on DevForum but most of them use if statements. I want it to find names by itself (I hope my idea is clear enough)
How it looks in Explorer
Any ideas?