This is the specific part of code that is throwing the error:
for _, obj in pairs(part:GetChildren()) do if not obj:IsA("Script") and not obj:IsA("Folder") then obj:Clone().Parent = part end end
Whenever I do:
for _, obj in pairs(part:GetChildren()) do if obj:IsA("Script") then obj:Clone().Parent = part end end
No errors occur.
Use ClassName
Instead of IsA
. IsA brings back a whole class set, while ClassName selects a certain class.
for _, obj in pairs(part:GetChildren()) do if obj.ClassName ~="Script" and obj.ClassName ~="Folder" then obj:Clone().Parent = part end end
Then
for _, obj in pairs(part:GetChildren()) do if obj.ClassName =="Script" then obj:Clone().Parent = part end end
IsA Examples: http://wiki.roblox.com/index.php?title=API:Class/Instance/IsA