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

How to make both the text transparency and image transparncy fade with a module script?

Only 1 of the 2 things fade while both of the things should fade at the same time

Main Script

local TextModule = require(script.TextModule)


function MakeUIAlive()
	TextModule.fadetext(script.Parent.Warn1.ContiuneLabel)
	TextModule.FadeIcon(script.Parent.Warn1.HeartIcon)
end

Module Script

local TextModule = {}

function TextModule.fadetext(FlashIcon)
	local CurrTrans = 0
	while true do
		for count = 1,100 do
			CurrTrans = CurrTrans + .01
			FlashIcon.TextTransparency = CurrTrans
			FlashIcon.TextStrokeTransparency = CurrTrans
			wait(.01)
		end

		for count = 1,100 do
			CurrTrans = CurrTrans - .01
			FlashIcon.TextTransparency = CurrTrans
			FlashIcon.TextStrokeTransparency = CurrTrans
			wait(.01)
		end
	end
end

function TextModule.FadeIcon(FlashIcon)
	local CurrTrans = 0
	while true do
		for count = 1,100 do
			CurrTrans = CurrTrans + .01
			FlashIcon.ImageTransparency = CurrTrans
			wait(.01)
		end

		for count = 1,100 do
			CurrTrans = CurrTrans - .01
			FlashIcon.ImageTransparency = CurrTrans
			wait(.01)
		end
	end
end

return TextModule

1 answer

✓ Accepted answer

when you require the module you are essentially importing that code into the current script, so its like having back to back while/for loops and so it will wait for one to complete before running the next. To run them both you have several options:

1)You could create a new function in the module script that does both at the same time

2)You can run the functions from different scripts

3)You can run the functions on different threads, there are multiple ways of doing this so you should pick which fits you best, here are some resources for multi-threaded methods in Roblox Lua:

youtube video going through methods

Forumn Thread with some good replies

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