|
| 21 Jun 2016 01:19 PM |
So I'm working on a weld script (incomplete) from stuff I'm learning on the wikis and from models I've inspected, and I noticed that when stating the classnames I'm supposed to put a [i] and use a local prev, which I can't find anything on. Can anyone explain what these are? This is the script.
------------------------------- local Children = script.Parent:GetChildren()
for i = 1,#Children do if ((Children[i].className == "Part") or (Children[i].className == "Wedge") or (Children[i].className == "Handle") or (Children[i].className == "Hitbox")) then print("Parts have been registered.") end end -------------------------------
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 21 Jun 2016 01:22 PM |
for _,part in pairs(script.Parent:GetChildren()) do if part:IsA'BasePart' then print(part.Name, ' is a part.') end end |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2016 03:17 PM |
Ok, sorry, I think I phrased that wrong. What I mean is why is local prev put into the local values if it doesn't equal anything. I know it works, I just don't know why so I can apply it late. Also, why do I need to for [i] between the Children and className for the script to work? Here's a bit of an updated but still incomplete version of the script.
---------------------------------- local PREV local Children = script.Parent:GetChildren() local Part = script.Parent.Part local Wedge = script.Parent.Wedge local Hitbox = script.Parent.Hitbox local Handle = script.Parent.Handle
for i = 1,#Children do if ((Children[i].className == "Part") or (Children[i].className == "Wedge") or (Children[i].className == "Handle") or (Children[i].className == "Hitbox")) then if (prev ~= nil) then end end end
|
|
|
| Report Abuse |
|
|