How do i get every single button under StarterGUI without making massive code trees?

If the title did not explain it: I hve many UIs with many folders inside of them with masny buttons and with many frames, so making a ton of loops to get to buttons would be way too custom for each UI and create massive code trees.

I was wondering if there is a simpler way of obtaining all of the UI button instances.

Note: All buttons are under StarterGUI and are SurfaceUIs

2 Likes
local Buttons = {}
for i,v in pairs(game.StarterGui:GetDescendants()) do 
   if (v:IsA("TextButton")) --[[or whatever you want]] then 
       Buttons[#Buttons+1] = v
   end
end
print("Found "..tostring(#Buttons).." buttons.")
print(Buttons)
3 Likes
local Buttons = {}


for i,v in parirs(game.StarterGui:GetDescendants()) do
 if v:IsA("TextButton") or v:IsA("ImageButton") add others here then
  table.insert(Buttons,v)
 end
end

And now you can just loop through buttons

2 Likes

GetDecendants() return every child under that specific instance? Even if the child is under liek 5 other childs?

yes (i literally have nothing to say more you explained everything by yourself)

1 Like

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