Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

i want to clone a model but the script doesn't working , why?

I want to clone a model but the script doesn't work and it doesn't give me any error in the output, what did I do wrong?

local a = script.Parent:Clone().Parent
a.Parent = workspace
a.Name = "arms"

1 comment

0

Remove that .Parent from the variable.

2 answers

✓ Accepted answer

When you clone an Instance, the newly created Instance will be identical to the original instance, except for two differences:

  1. The Instance's children will be clones of the corresponding original children.
  2. The instance's Parent will be set to nil.

Now, looking at point 2, we can see that local a = script.Parent:Clone().Parent sets a to nil. I'm quite surprised that you didn't receive an error message in the output, since on the next line the code accesses a nil value, trying to set its Parent to workspace. Make sure that the cloning code is actually being executed.

As for fixing it, look at your Instance hierarchy. The appropriate code might be local a = script.Parent:Clone() or local a = script.Parent.Parent:Clone(), depending on how your game is set up.

1 comment

0

ok , thanks. its working :D

This discussion is preserved as it was. New answers, comments, and votes are closed.