Search code examples
luaroblox

Getting on click using getchildren()


I have an area which has button numbers from 0 to 9 on roblox studio and I want to get all the children from that folder and also get the clickdetector for all of them but I dont know how. Please help thank you.

Managed to get the children but didnt manage to get the click detector


Solution

  • I assume you also want to get the click detector for all of the buttons, so here you go.

    local folder = --reference
    local t = {}
    
    for i,v in pairs (folder:GetChildren()) do
      if v:FindFirstChild("ClickDetector") then
          table.insert(t,v)
      end
    end
    
    --do whatever you want next now because you have the objects/buttons you want