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 6 years ago

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

this is my code so far

for i=1,10 -.1 do

    script.Parent.Transparency = (i)
end

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 6 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 :

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

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 — 6y
0
No problem. :D User#20279 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
for i=.01, 1.01, .01 do
    script.Parent.Transpareny = (i)
    wait(.01)
end

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

Answer this question