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

Text not going transparent at desired time?

Hi, so I have a script that is supposed to make the text become transparent when finished loading. It works with my other text box though. What is wrong with it and how can I get it to become transparent when done loading so it doesn't stay at the top.

function c(value)
	script.Parent.TextStrokeTransparency = value
	wait(0.05)
end

while true do
	c(0.9)
	c(0.8)
	c(0.7)
	c(0.6)
	c(0.5)
	c(0.4)
	c(0.3)
	c(0.2)
	c(0.1)
	c(0)
	c(0.1)
	c(0.2)
	c(0.3)
	c(0.4)
	c(0.5)
	c(0.6)
	c(0.7)
	c(0.8)
	c(0.9)
	c(1)
end

1 answer

✓ Accepted answer

Using that much code is very unnecessary, and just makes it look inefficient; there's a better way of going about fixing your code, however, I would like to address the problem w/ your code:

Problem: You created a function that would change the Text Transparency; that is not a bad idea, however, it lead to using a lot of unnecessary code.

This can be fixed, however, by using a For loop (not the Generic For loop). The For code should look something like this:

for i = START_VALUE, END_VALUE, ADJUSTMENT_VALUE do
	print('Yo. c:')
end

Now, to explain the For loop: the for loop is somewhat like the While loop and Repeat loop, however, they're different by one big difference: the for loop starts w/ a start value (being START_VALUE), and ends w/ an end value (being END_VALUE), and when the start is equal to the end (or pretty close), the looped code will automatically stop running; another advantage is that you can change its adjustment; 1 is its default adjustment value, however, you can change it (the value being ADJUSTMENT_VALUE ).

Now, w/ all that out of the way, let us begin the process!

function c(value) -- No change required here
	script.Parent.TextStrokeTransparency = value
	wait(0.05)
end -- Ends code chunk

Note: There's no need to edit your function, as we can keep it the same way; all we have to do is change what's within the While loop. :)

function c(value) -- No change required here
	script.Parent.TextStrokeTransparency = value
	wait(0.05)
end -- Ends code chunk

while true do
	for i = 1, 0, -0.1 do
		c(i) -- Will change the value to value 'i'; 'i' is a variable for the current number being used in the loop (A bit hard to explain ;-;)
	end
	for i = 0, 1, 0.1 do
		c(i)
	end
end

And... Ta-da! All done! :D

I really hoped this helped you w/ your question. :)

3 comments

0

I take it I answered the question? :D

0

Thanks! :D

0

@BunnyFilms1 Np! :D

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