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?
--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
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?