I write a command about transparency, but I want to loop it, I knew how to, but I kind of forget, I remember it's like "for i" something like, so can anyone help me remember?
while true do script.Parent.Transparency = 0.1 wait(1.5) script.Parent.Transparency = 0.2 wait(1.5) script.Parent.Transparency = 0.3 wait(1.5) script.Parent.Transparency = 0.4 wait(1.5) script.Parent.Transparency = 0.5 wait(1.5) script.Parent.Transparency = 0.6 wait(1.5) script.Parent.Transparency = 0.7 wait(1.5) script.Parent.Transparency = 0.8 wait(1.5) script.Parent.Transparency = 0.9 wait(1.5) script.Parent.Transparency = 1 end
I can just do that but I think there is a easier way!
Yes you are correct, there is an easier way.
for i = 1,10 do script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(1.5) end
If you want it looped it would be...
while true do for i = 1,10 do script.Parent.Transparency = script.Parent.Transparency + 0.1 wait(1.5) end for i = 1,10 do script.Parent.Transparency = script.Parent.Transparency - 0.1 wait(1.5) end end
Helpful Link: http://robloxdev.com/articles/Roblox-Coding-Basics-Loops#For
Use for loop.
for i = 0,1, 0.1 do wait() script.Parent.Transparency = i end
Just like that. 0.1, is the increment of the transparency.
You can use for loops:
for i = 0, 1, 0.1 do script.Parent.Transparency = i wait(1.5) end
Or, you can use TweenServices, which are a bit more complicated, but are easy to understand nonetheless:
https://wiki.roblox.com/index.php?title=API:Class/TweenService/Create
for loop = 1,10 do wait() script.Parent.Transparency = loop/10 end
If you're trying to loop a particle emitter transparency, look into "NumberSequence".