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

Fade In Script Non Functional?

local GuiHolder = script.Parent.Holder
local MovingBars = script.Parent.Holder.MovingBar
local Bars = script.Parent.Holder.Bar
local Background = script.Parent.Holder.Background
local PickAToon = script.Parent.Holder.PickAToonGui

--This Bellow will tell the script to wait before it comes in/fades in--
wait(8)
Background.ImageTransparency = 1
for i = 1,0,-0.1 do --make it invisible
Background.ImageTransparency = i
if Bars.BackgroundTransparency == 1 and
MovingBars.BackgroundTransparency == 1
then for i = 0,5,-0.1 do --make it invisible
Bars.BackgroundTransparency = i
MovingBars.BackgroundTransparency = i
wait(0.1)
end
end

when i play it i dont see the gui fading in but before when i had only the Background to fade in that worked. Not sure what im doing wrong but the Bars and MovingBars HAVE TO BE 0.5. Help thx!

1 answer

✓ Accepted answer

You cannot have a for loop inside a for loop.

I cleaned up your code:

local GuiHolder=script.Parent.Holder
local MovingBars=GuiHolder.MovingBar
local Bars=GuiHolder.Bar
local Background=GuiHolder.Background
local PickAToon=GuiHolder.PickAToonGui
--This Bellow will tell the script to wait before it comes in/fades in
local function Fade(target,in,to)--set target to the thing you want to fade, set in to true to fade in and false to fade out, and set to to what value to stop at
	wait(8)
	for i=0,a=20 do--change 20 to how many times you want to run this
		local val
		if target:IsA'ImageLabel' or target:IsA'ImageButton' then
			if in==true then
				target.ImageTransparency=(i/a)*to
			else
				if val=nil then
					val=target.ImageTransparency
				end
				target.ImageTransparency=val-((i/a)*to)
			end
		else
			if in==true then
				target.BackgroundTransparency=(i/a)*to
			else
				if val=nil then
					val=target.ImageTransparency
				end
				target.BackgroundTransparency=val-((i/a)*to)
			end
		end
		wait(.1)
	end
end
--now just call the function with the correct arguments

may not be the most compact, but should work i think

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