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

I do not know what has gotten into me with for loops can someone help?

Well, I used to know for loops I guess? I tried scripting a for loop today to make a Part transparent it goes transparent by 0.1 at a time but stays transparent does not repeat to 0?

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

2 answers

you told the loop, to start at 0, end at 1, and go by an increment of 0.1 Of course it won't go back to zero because you told it to stop once it ends at 1.

Yeah obviously, because it only runs once, and when it finishes gradually turning it to transparency 1, it stops.

You should use a while true do loop, that keeps running as long as the script is active, and make it go visible agian, like so:

while true do
	for i = 0, 1, 0.1 do 
 		script.Parent.Transparency = i
  	 	wait(0.5)
	end
	for i = 0, -1, -0.1 do 
 		script.Parent.Transparency = i
  	 	wait(0.5)
	end
end

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