From my experience, I would recommend having the iterated For loop outside of the Generic For, and not vise-versa.
With how you set up your code, it, in a nutshell, is doing the following:
And not:
I would also recommend using the IsA function, as a just-in-case if there's an object that isn't a part in the model object; what it does is is it checks to see if a object(s)'s ClassName, or type, is that specific object type.
With all that in mind, lets go on ahead & work on the code. :P
First off, we want to plug in the Iterated For Loop first before plugging in the Generic For:
local ForIterationValues = {
StartValue = 0,
EndValue = 1,
Increasement = 0.1
}
for i = ForIterationValues.StartValue, ForIterationValues.EndValue, ForIterationValues.Increasement do
end
Second, we can now plug in the Generic For; however, DO NOT put it outside of the Iterated For Loop if you want to accomplish what you're (wanting it to) doing, as vise-versa will not result in what you're trying to do:
local ForIterationValues = {
StartValue = 0,
EndValue = 1,
Increasement = 0.1
}
for i = ForIterationValues.StartValue, ForIterationValues.EndValue, ForIterationValues.Increasement do
for part in pairs({game.Workspace.BasePlate}) do
if part:IsA('BasePart') then
part.Transparency = i
end
end
coroutine.yield()
end
And that's pretty much it, believe it or not. e-e
However, to note, I didn't rewrite your script for you; that's your job. The above code(s) are only to be used, and are intended to be used, as references.
Stuff touched on, but got into detail about
To go to the WIKI/ Documents on the below, click the highlighted words. :)
The For loop.
The Generic For
- Well, I gotta touch on this: what the generic for does is iterate through a table, and it defines (if you have two variables, like "i, v", then you use "v", but if it's stand alone, you use that variable ONLY) the current iterated object w/ the/ a variable.
The IsA Function.
ClassName
- Gotta touch on this too: this is a property that ALL objects have, and it tells/ shows the type the object is; say you want to know the WorkSpace's type, you just do
print(Workspace.ClassName), and it should print something like Workspace. That's essential what does. :P However, you can NOT change the property value at all, otherwise your code will break.
Hope this helped you in any way! ;D
1 comment
2lazy2putin: Another noticeable problem is that you didn't set up the iterated for correctly; you set it up as "for i = start value, end value - 0.05," and not "for i = start value, end value, -0.05."