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

how to smoothly change a value?

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

✓ Accepted answer

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.

2 comments

0

thank you!

0

No problem. :D

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.

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