Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Adjusting ScreenGui Transparency?

I have a ScreenGui that has a lot of ImageLabels, TextLabels, Frames, etc. and I would like to adjust the transparency of ALL objects within that ScreenGui to add a fading effect when entering the game.

So instead of doing each one by line, I'd like to use GetChildren, and find if each child has 1 or more transparency properties, and adjust the transparencies to a set variable if it does.

So here is what I have so far:

function Fade()
	for	i = 0.05, 1, 0.05 do
		for index, child in pairs(script.Parent.Parent:GetChildren()) do --script.Parent.Parent is the ScreenGui
			if child.Transparency ~= nil then
				child.Transparency = i
			end
			if child.TextTransparency ~= nil then
				child.TextTransparency = i
			end
			if child.BackgroundTransparency ~= nil then
				child.BackgroundTransparency = i
			end
			if child.ImageTransparency ~= nil then
				child.ImageTransparency = i
			end
		end
		wait(0.05)
	end
	script.Parent.Parent:Destroy()
end

1 answer

It depends on what is in the ScreenGui. You will need to find if the thing you are changing transparency is a TextLabel/Button/Box (For the text ones) or an ImageLabel (For the image label) OR both, depending on what else is in the ScreenGui (for the background). I can't quite remember how to do this, try the wiki. If not, just write it out. I do it all the time.

1 comment

0

That's why I do if child.Transparency ~= nil then but that doesn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.