Pretty simple question: How do I make the Parent of this script (Which is a transparent Part) turn opaque with steps of 0.1 and a speed of 0.1 seconds.
for i=1,0, -0.1 do script.Parent.Transparency = (i) end
Your script works fine, the only problem is you aren't waiting! ROBLOX has this nice function named wait which halts the script for the amount of seconds input into the function. This is useful for pauses of all kinds, including the one you want!
for i=1,0, -0.1 do wait(0.1) script.Parent.Transparency = i end
for i=1, 10 do wait(.1) script.Parent.Transparency = script.Parent.Transparency + 0.1 end
This will add 10% transparency to the part every 1/10th of a second
Simple:
for i=1,0, -0.1 do script.Parent.Transparency = (i) wait(.1) end
Or if you mean .1 seconds for the whole thing:
for i=1,0, -0.1 do script.Parent.Transparency = (i) wait(0.01) end
You can calculate the time needed to wait like this. I included nice variables so you can change it up easily.
local speed = 0.1 --Time in seconds local stepsize = 0.1 --Step size for i = 1, 0, -1*stepsize do script.Parent.Transparency = i wait(speed*stepsize) end
If you want a function, here you go:
function animateTransparency(part, seconds, stepsize, endTransparency) while part.Transparency != endTransparency do if part.Transparency < endTransparency then if part.Transparency + stepsize > endTransparency then part.Transparency = endTransparency else part.Transparency = part.Transparency + stepsize end else if part.Transparency - stepsize < endTransparency then part.Transparency = endTransparency else part.Transparency = part.Transparency - stepsize end end wait(seconds*stepsize) end end --And usage example: animateTransparency(script.Parent, 0.1, 0.1, 0)