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

How could I make this shorter?

I am making a hint GUI but I want the script below smaller.

script.Parent.TextTransparency = 0.1
wait(0.1)
script.Parent.TextTransparency = 0.2
wait(0.1)
script.Parent.TextTransparency = 0.3
wait(0.1)
script.Parent.TextTransparency = 0.4
wait(0.1)
script.Parent.TextTransparency = 0.5
wait(0.1)
script.Parent.TextTransparency = 0.6
wait(0.1)
script.Parent.TextTransparency = 0.7
wait(0.1)
script.Parent.TextTransparency = 0.8
wait(0.1)
script.Parent.TextTransparency = 0.9
wait(0.1)
script.Parent.TextTransparency = 1

Any help?

4 answers

--Sorry if not coded right

for i=1,script.Parent.TextTransparency,0.1 do
script.Parent.TextTransparency=script.Parent.TextTransparncy-i
end

Ok so since an administrator tells me to "Explain", I shall.

For loops are loops thats have either 2 or 3 arguments and are a variable by "i" or something else like "bacon". They run from the start number to the end number. The third argument can decide how much the variable goes up by every time it repeats itself.

Note: The third argument is optional. If you don't put a third argument, then it will add +1 by default.

Lets say u typed..

for cheese = 7,10,.1 do
	print(cheese)
end

or...

for cheese = 7,10 do
	print(cheese)
end

If you ran the script it should've went from 7 to 10 and adding .1 every time it looped in your output. If you ran the SECOND script it shouldve went 7,8,9,10. This goes back to my note. It automatically sets the third argument to 1 if nothing is there.

Now, the script I'm about to give you fixes your issue but I will guide you to how it works.

for i = 0,1,.1 do  --starts from zero and goes to one while adding .1 to i by every loop
	script.Parent.TextTransparency = i -- transparency is now the given value "i"
	wait(.1) --waits .1 seconds before redoing the loop and adding .1 to "i"
end

2 comments

0

It works but, how would I make the transparency go down?

0

change the second line to script.Parent.TextTransparency = 1 - i

Here's the code

repeat
	script.Parent.TextTransparency = script.Parent.TextTransparency -0.1
until
script.Parent.TextTransparency == 1
for i = 1,10,1 do
	script.Parent.TextTransparency = i/10
	wait(.1)
end

Happy?

2 comments

0

You just copied Tochi's script and took out the comments. ._.

0

Actually no I didn't, I didn't even look at the previous answers. :/ I'll do it a different way if it'll make you happy..

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