Right before I explain, there is a WIKI Documentation about this specific topic. :P
How to properly use a For loop?
As the WIKI says, The for loop is a way of running a command or set of commands a set number of times., in other words, how many times to run it (Or, in other words (again), how many times it should run), as you'll sometimes see;
for i = 1, 5 do
print(i)
end
There are multiple ways of using it, as such the code you are using, however, looking at the code, there are errors in it, not a lot, but some errors (not the type that break your code execution, but coding errors). Lets take a look at your code;
for i = 0, 17.3, .01 do
for a,v in pairs(script.Parent:GetChildren()) do
if not v:IsA("Script") then
v.Position = v.Position + Vector3.new(0,.01,0)
wait(.1)
end
end
end
There are multiple errors within it (that I can notice), allow me to point them out;
for i = 0, 17.3, .01 do
for a,v in pairs(script.Parent:GetChildren()) do
if not v:IsA("Script") then
v.Position = v.Position + Vector3.new(0,.01,0)
wait(.1)
end
end
end
As I have pointed out, there are 2 errors in your code, however, these can be fixed by changing a bit of the code;
for i = 0, 17.3, .01 do
for a,v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.CFrame = v.CFrame + Vector3.new(0,0.01,0)
end
end
wait(.1)
end
Ahh, now doesn't your code look much better? :)
Information left out
In-case you don't know (Don't mean to make that sound rude :c ), a BasePart is a (I don't really know how to explain this, so I'll do as best I can! :D ) String (Used for the 'IsA' method) to specify a specific Part's type (Like the ClassName property of every Part, which tells it's Part type, 'IsA' does the same thing, but only it can use the 'BasePart' String (or function) to it's advantages to check a Child's Property) (Basically like it's it's own 'for' loop; it's like it loops though a 'Table' to determine which 'ClassName' property a Part's 'ClassName' is. Amazing, isn't it? :D ).
Hope this helped!
2 comments
It just takes a long time to finish because you're going up by .01, and waiting .1 seconds each time. At this rate, it would take 1730 seconds to finish. Remove the wait, or change it to wait() for it to take less time.
Sorry, 173 seconds, not 1730.