Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to smoothly change a value?

Asked by 7 years ago

I was wondering how to smoothly fade out a block with the transparency value

this is my code so far

1for i=1,10 -.1 do
2 
3    script.Parent.Transparency = (i)
4end

this instantly fades out the block when I run the game, is there any way to delay the counting so its slower and not instant?

2 answers

Log in to vote
0
Answered by 7 years ago

You forgot to add a wait() into it so it would instantly fade, plus you didn’t put the right values on the loop for transparency, as it’s supposed to be 1,0 or 0,1.

Here’s a fixed version of your script :

1for i = 0, 1, .1 do
2wait(.1)
3script.Parent.Transparency = i
4end

You can change the 0, 1 into 1, 0 if you want it to fade in. You can also change the wait() if you want it to fade faster or slower.

0
thank you! retracee 68 — 7y
0
No problem. :D User#20279 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
1for i=.01, 1.01, .01 do
2    script.Parent.Transpareny = (i)
3    wait(.01)
4end

Change the wait function to a higher number like .02 if you wanted it to go faster.

Answer this question