So i have a code that clones all objects from workspace and i want to move then to viewport frame, but it keeps saying me that cloned objects don’t have parent? Here’s code and output screenshot:
So the thing is when cloned object has parent is says it parent, other way it says no parent. I still can’t understands why, because as you can see the object exists and it’s name too, but parent is nil. Any help would be apprieciated.
clone didn’t return nil, it returned object but with no parent, i mean, parent is nil as parameter. So, let me explain, object exists and it’s name, but Parent parameter doesn’t, so i can’t set it or either read it, cuz it’s doesn’t exist at all for script.
Do you understand what the error message meant? “Attempt to index nil” is when you run the dot operator on something that is nil. You can only run the dot operator on tables(in this case, an instance which is technically a table), but you tried using it on a nil value. That means that the variable a IS nil, therefore the cloned instance doesn’t exist nor does its name.
The only reason why :Clone() would return nil is because the instance you tried to clone is not archivable. Perhaps you should look into that.
At this point, the issue might not be because of the clone function. I would double-check the script that’s responsible for the cloning; try printing out the object that it’s trying to clone and the cloned object and adding a check to make sure the cloned instance actually exists.