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

Help with part cloning?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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

Log in to vote
2
Answered by 8 years ago

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.

Ad
Log in to vote
0
Answered by 8 years ago

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

Answer this question