How to delete specific elements from inside a frame?

Greetings,

I have a frame and inside of them, there are a couple of elements and most importantly some text labels. How can I do it so that a script deletes the text labels when a button is pressed? Thanks.

You can loop through all the children within the frame and check for their class using the :IsA(classString) method.

for _ , object in pairs(frame:GetDescendants()) do
     if object:IsA("TextLabel") then
        object:Destroy()
     end
end
1 Like

Thanks, exactly what I was looking for. And how can I do it for any object, but with a specific name?

If you mean by name checking, just switch if object:IsA("TextLabel") then to if object.Name == "anything" then.

1 Like