GetChildren not grabbing any of the children?

So I have thisi script that gets the children of a frame and the children and guis, and then it transparencys in a second, but it doesnt work? any help?

local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()

local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren()

script.Parent.frameBackground.Visible = true

wait(2)

dog.ImageTransparency = 0.1

dog2.ImageTransparency = 0.1

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.1

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.1

wait(0.1)

dog.ImageTransparency = 0.2

dog2.ImageTransparency = 0.2

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.2

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.2

wait(0.1)

dog.ImageTransparency = 0.3

dog2.ImageTransparency = 0.3

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.3

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.3

wait(0.1)

dog.ImageTransparency = 0.4

dog2.ImageTransparency = 0.4

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.4

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.4

wait(0.1)

dog.ImageTransparency = 0.5

dog2.ImageTransparency = 0.5

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.5

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.5

wait(0.1)

dog.ImageTransparency = 0.6

dog2.ImageTransparency = 0.6

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.6

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.6

wait(0.1)

dog.ImageTransparency = 0.7

dog2.ImageTransparency = 0.7

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.7

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.7

wait(0.1)

dog.ImageTransparency = 0.8

dog2.ImageTransparency = 0.8

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.8

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.8

wait(0.1)

dog.ImageTransparency = 0.9

dog2.ImageTransparency = 0.9

script.Parent.frameBackground.imageBackgroundPattern.ImageTransparency = 0.9

script.Parent.frameBackground.imageBackgroundPattern2.ImageTransparency = 0.9

wait(0.1)

dog.ImageTransparency = 1

dog2.ImageTransparency = 1
2 Likes

Two things, 1:

Please use for loops, they can prevent extremely long scripts like the one you have here, for example

local thing = workspace.Thing
for i = 0,1,0.1 do
   thing.Transparency = i
end

Second thing, GetChildren() returns a table, which doesn’t really have Transparency Property, so you would have to do something like this

local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()
for _,thing in next, dog do
   thing.ImageTransparency = 0.1
end

With that said, you could probably do something along the lines of this:

local FBG = script.Parent.frameBackground
local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()
local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren()

for i = 0,1,0.1 do
   FBG.imageBackgroundPattern.ImageTransparency = i
   FBG.imageBackgroundPattern2.ImageTransparency = i
   wait(0.1)
end

for i,v in next, dog do
   v.ImageTransparency = i
   wait(0.1)
end
for i,v in next, dog2 do
   v.ImageTransparency = i
   wait(0.1)
end

without further knowledge of your hierarchies, any further simplification isnt really possible

2 Likes

:GetChildren returns a table containing the children found in the respected object, this makes dog a table of everything inside frameBackgroundBottom. If you want to change all of the contents to a certain transparency you would need to use a for loop in order to set each object inside the table.

for _,v in pairs(dog) do
    v.ImageTransparency = 0.1
end
1 Like

If I were you, I would have a function to loop through all the children and use tweenservice to tween the ImageTransparency if its an imagelabel

local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren();
local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren();

local imageBackPat = script.Parent.frameBackground.imageBackgroundPattern;
local imageBackPat2 = script.Parent.frameBackground.imageBackgroundPattern2;

script.Parent.frameBackground.Visible = true;

local inf = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0);
local goal = {ImageTransparency = 1;}

local ts = game:GetService("TweenService");

local function transp(children)
	for x,y in pairs(children) do
		if y:IsA("ImageLabel") or y:IsA("ImageButton") then
		
		local tween = ts:Create(y, inf, goal);
		tween:Play();
		
		end;
	end;
end;

transp(dog);
transp(dog2);

-- Then just use tweenService to tween your imageBackgroundPatterns
local tween = ts:Create(imageBackPat, inf, goal);
tween:Play();

local tween2 = ts:Create(imageBackPat2, inf, goal);
tween2:Play();
2 Likes