Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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"

0
Remove that .Parent from the variable. SmartNode 383 — 4y

2 answers

Log in to vote
0
Answered by
gskw 1046 Moderation Voter
4 years ago

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.

0
ok , thanks. its working :D Premiumaleprosito 0 — 4y
Ad
Log in to vote
0
Answered by
WoTrox 345 Moderation Voter
4 years ago

Remove the .Parent at the first lines end

Answer this question