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

Help with part cloning?

What I am trying to do is make this part clone every 2 seonds but instead of that it just clones but multiplies

while true do
	wait(2)
Part = script.Parent:Clone()
Part.Parent = script.Parent.Parent
end

2 answers

Use logic! You are cloning the script that makes this multiply every two seconds as well. This is because cloning an object also clones their descendants, in this case this script.

If you wanted a cheap solution, just disable any scripts in the new clone:

while true do
    wait(2)
	Part = script.Parent:Clone()
	Part.Parent = script.Parent.Parent
	for _, v in pairs(Part:GetChildren()) do
		if v:IsA("Script") or v:IsA("LocalScript") then
			v.Disabled = true
		end
	end
	print(1)
end

But really you think through what you want to be cloning.

Here's an easier solution, and you can reduce your code by one line, although I'm not exactly sure what you mean when you say that it multiplies.

while wait(2) do
	local part = script.Parent:Clone()
	part.Parent = script.Parent.Parent
end

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