Because GetChildren does not identify me ImageButton

my problem is that the script placed in gui, where I set GetChildren, does not read ImageButton generated by a localscript and to get around the problem they suggested me to use a remote event but I haven’t solved the problem yet

can you at least provide the script please?

script

 while wait() do
    for i,e in pairs(script.Parent.Frame:GetChildren()) do
		if e:IsA("ImageButton") then
			e:Clone().Parent = workspace.table1.ff.player1.Part1_a.cff.SurfaceGui
		end
    end
end

localscript

local NI= 0

while wait() do
	
	if NI == 9 then
		
	else
		
	
		local E =  script.Parent.ggg:GetChildren() --random card

		local chi = E[math.random(1, #E)]	
		for _,G in pairs(chi:GetChildren()) do
			if G:IsA("Frame") then
				if G.Name == "rt" then
					G:Destroy()
				end
			end
		end
		
		
		chi:Clone().Parent = game.Players.LocalPlayer.PlayerGui.aaaa.Frame
        NI+=1
		for _,G in pairs(game.Players.LocalPlayer.PlayerGui.aaa.Frame:GetChildren()) do
			if G:IsA("UIGridLayout") then
				if G.Name == "BOB" then
					NI-=1
					G:Destroy()
				end
			end
		end
	end
end