I want to clone a model in a localscript and then set it’s parent to something else. Problem is, when I try to set the parent of the cloned model in the script, it gives an error saying “attemp to index nil with ‘Parent’”
My code is this:
This output error still occurs when I remove all the models from my workspace. Does anyone know how to fix this?
This is what the workspace looks like:

[SOLUTION] I solved it myself by realizing that the player character is also getting cloned and character models archivable are set to false so they can’t clone.
Can I see what’s under workspace?
I edited the post to show the workspace now.
Okay, I think you should make a variable of that Clone part, then you refer that variable and specify it’s parent. Maybe that will fix the problem.
It doesn’t but I already found out what was causing the problem. Turns out, I was also cloning the player’s character model and that model’s archivable is set to false. You cannot clone an instance with archivable set to false so that’s why my script broke.
2 Likes
Smart, now you can mark that comment as the solution.
You need to make a variable and check if it’s existed, replace the code in line 4 with this.
if aKid ~= nil then
local kid = aKid:Clone()
kid.Parent = script.Parent.ViewportFrame
end
end
Thanks for reminding, this was my first post so I’m still getting used to the forums 
1 Like
That’s close to what I did. Turns out, I needed to check if the cloned kid is nil or not. This is because while the kid is not nil, if the kid’s archivable is set to false it won’t clone, hence the cloned kid being nil.
Add if statement when the item is archivable.
1 Like