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

How do I clone a part at another parts position?

Asked by 10 years ago

I have coding here:

Emitter = script.Parent.Emitter
clonepart = script.Parent.part2clone

while true do
    wait (1)
    clonepart:Clone()
end

Could anyone help? I don't know how to do it, and I really want to make what I am making.

3 answers

Log in to vote
0
Answered by 10 years ago

You will have to define a variable for the clone you make. This way you can change it's properties.

local Emitter = script.Parent.Emitter -- Defines variables with local
local clonepart = script.Parent.part2clone

while wait(1) do -- This loop runs every second
    local clone = clonepart:Clone() -- define a variable that holds the new clone
    clone.Position = Emitter.Position -- Set the clones position to the emitters position   
end
Ad
Log in to vote
0
Answered by 10 years ago

I see two errors; You didn't set the Part's Parent, thus its Parent was nil, and you didn't set the Position for the Part to position at, lets fix this, shall we;

repeat wait() until script.Parent and script.Parent:FindFirstChild("Emitter") and script.Parent:FindFirstChild("part2clone") --This will repeat waiting until the script finds these requirements
local Emitter = script.Parent.Emitter --This is the Main Part [Where the Part will Spawn at]
local clonepart = script.Parent.part2clone:Clone() --This will Clone the Part
clonepart.Parent = script.Parent --This will set the Cloned Part's Parent to the script's Parent
clonepart.CFrame = Emitter.CFrame --This will set where the Part will spawn; Will set the Part's CFrame the same as 'Emitter''s

Hope this helped!

Log in to vote
0
Answered by
TopDev 0
10 years ago

All you needed was to define the parent, you was cloning it but not defining the parent, thus doing nothing.

Emitter = script.Parent.Emitter
clonepart = script.Parent.part2clone

while true do
    wait (1)
    clonepart:Clone().Parent = clonepart.Parent
end

Answer this question