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?
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
: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
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();