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

How do I clone a part at another parts position?

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

✓ Accepted answer

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

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!

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

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