How to use wait for child on multiple instances with the same name

I was recently trying to make a clicking system and I had five objects with the name crate, and I used

Orbs:WaitForChild("Crate").ClickBox.ClickDetector.MouseClick:Connect(function()

But it would only get one how could I use WaitForChild to reference all the objects named “Crate”

for _,crate in pairs(workspace:GetDescendants()) do
    if crate.Name == "Crate" then
        crate.ClickBox.ClickDetector.MouseClick:Connect(function()
            ----------- your code here
        end)
    end
end

1 Like