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

Script that makes an image fade out doesn't work?

This script isn't working can someone help me? Its suppost to make 1 image fade in and the other fade out using the repeat until loop.

local z = script.Parent

while true do
	repeat
		wait(0.1)
		z.a.ImageTransparency = z.a.ImageTransparency - 0.01
	until
	z.a.ImageTransparency == 0
	
	wait(3)
	
	repeat
		wait(0.1)
		z.a.ImageTransparency = z.a.ImageTransparency + 0.01
	until
	z.a.ImageTransparency == 1

	repeat
		wait(0.1)
		z.b.ImageTransparency = z.b.ImageTransparency - 0.01
	until
	z.b.ImageTransparency == 0

	wait(3)

	repeat
		wait(0.1)
		z.b.ImageTransparency = z.b.ImageTransparency + 0.01
	until
	z.b.ImageTransparency == 1

	repeat
		wait(0.1)
		z.c.ImageTransparency = z.c.ImageTransparency - 0.01
	until
	z.c.ImageTransparency == 0

	wait(3)

	repeat
		wait(0.1)
		z.c.ImageTransparency = z.c.ImageTransparency + 0.01
	until
	z.c.ImageTransparency == 1

	repeat
		wait(0.1)
		z.d.ImageTransparency = z.d.ImageTransparency - 0.01
	until
	z.d.ImageTransparency == 0

	wait(3)

	repeat
		wait(0.1)
		z.d.ImageTransparency = z.d.ImageTransparency + 0.01
	until
	z.d.ImageTransparency == 1
	
	repeat
		wait(0.1)
		z.e.ImageTransparency = z.e.ImageTransparency - 0.01
	until
	z.e.ImageTransparency == 0

	wait(5)

	repeat
		wait(0.1)
		z.e.ImageTransparency = z.e.ImageTransparency + 0.01
	until
	z.e.ImageTransparency == 1
	
end

1 comment

0

no no no no no no no no no !

1 answer

✓ Accepted answer

I explained everything that I did in the script. Hope this works.

local z = script.Parent
while wait() do -- same as while true, but yields 1/30th of a second
	local index = {"a","b","c","d","e"}
	
	for _, v in ipairs(index) do
		-- iterates through the table "index
		
		local imageLabel = z:FindFirstChild(v) 
		-- gets the imagelabel according to the index
		-- first z["a"], then z["b"] and so on
		
		if imageLabel then -- check imageLabel was found
		
			repeat
				-- Fade in
				wait(0.1)
				imageLabel.ImageTransparency = imageLabel.ImageTransparency - 0.01
			until imageLabel.ImageTransparency <= 0 -- <= because values aren't always certain

			wait(3)

			repeat
				-- Fade out
				wait(0.1)
				imageLabel.ImageTransparency = imageLabel.ImageTransparency + 0.01
			until imageLabel.ImageTransparency >= 1-- >= because values aren't always certain
			
			wait(3)
		else
			warn("Cannot find image label by the name of",v,"in",z.Name)
			continue -- go to the next iterable of the loop
		end
	end
	
end

If it did, please accept my answer. Let me know of any issues :)

1 comment

0

Thanks alot

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