Getting all the new values by GetDescendants

So basiclly i have a gui that will automatically added new TextButton in a ScrollingFrame
and i use GetDescendants() to get all the button, but the problem is that it get all the button before the other script can add the TextButton in.

So i need some way get all the new TextButton that just got added. Maybe a way to loop GetDescendants()

I have tried to loop it but still doesn’t work

while wait() do
 	button = script.Parent.Main:GetDescendants()
	for i,v in pairs(button) do
		if v:IsA("TextButton") then
-- Check what button is and fire some RemoveEvent

i tried to loop it with the for…do… loop but it fire the RemoteEvent like 20 times a sec cause my game to lag.

You can use the ChildAdded event to detect when there a new button has been added.

Here’s an example:

local function newChild(child) -- the child parameter is from the ChildAdded event
    if child:IsA("TextButton") then
        print('New text button!')