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

Am I using the Clone() function correctly?

So here is my code;

local clonePart = script.Parent

while true do
	newPart = clonePart:Clone()
	newPart.Parent = workspace
	wait(5)
end

Why is it not creating a new part every 5 seconds?

thanks in advance, guys.

4 comments

0

Is the part script.Parent?

0

The part I wish to clone is script.Parent, yes

0

Can you give me the Script type and location?

0

clonePart is in game.Workspace, and the script (which is a normal script - not local) is in game.Workspace.clonePart

2 answers

I think it's because lua reads code from top to bottom (line by line) so put wait (5) on line 2 And there's no need to clone a part when you can just instance a part. Keep in mind that cloning is essential if you want to instance the exact model while instance is useful if you just want to instance a part without changing its property try the below code.


while true do -- while loop
wait (1) -- waits a second
local part = Instance.new( "Part",game.Workspace) -- It instances a part and the put the part in the workspace
end

If my answer helped make sure to accept it

local clonePart = script.Parent

while true do
    local position = newPart.Position
    newPart = clonePart:Clone()
    newPart.Parent = workspace
    newPart.Position   = position * Vector3.new(0, 1, 0)
    wait(5)
end

I'm pretty sure this is working but the position is in the same spot so you can't tell

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