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

Cloning should be simple?

Asked by
emite1000 335 Moderation Voter
10 years ago

I sort of have to questions that both pertain to each other to post here:

1. Using the Clone() function is supposed to create a clone of the object, and "make the Parent become nil". What does making the parent become "nil" mean? Does it mean the parent is deleted and replaced by the clone?

2. I'm not sure where the default spawn space for this "clone" is supposed to be (above the Parent, at 0, 0, 0, at some random spot, whatever), so I decided to test out the Clone function with a simple script... but it does not work. Why?

script.Parent.Touched:connect(function(part)
    script.Parent:Clone().Position = Vector3.new(54.2, 2.2, 43.6)
end)

3 answers

Log in to vote
0
Answered by
Resnex 60
10 years ago

Try something along the lines of this:

CLONE = script.Parent:Clone()
CLONE.Parent = --whatever parent
CLONE.Position = Vector3.new(54.2, 2.2, 43.6)
0
Also, you need the line of code at the bottom to connect when it's touched. Resnex 60 — 10y
0
Tried that and got the error "startScript re-entrancy has exceeded 3". emite1000 335 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

The parent of the clone is not deleted. If it doesnt work, the script's parent (assuming it is a part) is not archivable. Check if it is archivable. If it is, you can clone it. If it isn't, you can't.

Log in to vote
0
Answered by 10 years ago

Question 1: 'Making the parent nil' means simply to place the clone in workspace. Question 2: It Vector3 moves to the position 0,0,0.

Script: Looks a bit off to me. Try this:

script.Parent.Touched:connect(function ()
    Clone = script.Parent:Clone()
    Clone.Position = Vector3.new(54.2, 2.2, 43.6)
end)

Also, why did you put in 'part' as an argument if you never used it? Taking it out may help.

0
Replaced my script with yours but no changes. Thanks for answer question 1, but I'm still completely baffled by why the script isn't working. emite1000 335 — 10y
0
Er, Emite, are you ABSOLUTELY SURE that the cloned object HAS a Position property? Things like models and fires don't. SquirreIOnToast 309 — 10y

Answer this question