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

The Script is right but cake won't spawn? Clone script help

Asked by 5 years ago
-- Script in game.Workspace.Cake.smallCake
while true do
    wait(6)
    local SmallCake = script.Parent
    local clonedSmall = SmallCake:Clone()
    local clonedSmall2 = SmallCake:Clone()
    local clonedSmall3 = SmallCake:Clone()
    local clonedSmall4 = SmallCake:Clone()
    local duplicated0 = clonedSmall:FindFirstChild("Script")
    duplicated0:Destroy()
    local duplicated1 = clonedSmall2:FindFirstChild("Script")
    duplicated1:Destroy()
    local duplicated2 = clonedSmall3:FindFirstChild("Script")
    duplicated2:Destroy()
    local duplicated3 = clonedSmall4:FindFirstChild("Script")
    duplicated3:Destroy()
    clonedSmall.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall.Position = Vector3.new(266.242, 831.029, -230.982)
    clonedSmall2.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall2.Position = Vector3.new(266.242, 831.029, -230.982)
    clonedSmall3.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall3.Position = Vector3.new(266.242, 831.029, -230.982)
    clonedSmall4.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall4.Position = Vector3.new(266.242, 831.029, -230.982)


end

This is a script I made. This script is inside a part that has a mesh and other welds. So it will basicly clone itself and get rid of the script to prevent the other scripts to run. This script just worked fine on the bigCake but doesn't work here. Help me!

0
Did you anchor the cake? aazkao 787 — 5y
0
is the `SmallCake` a Model or Part? Run the script and check workspace to see if the cakes spawned. hellmatic 1523 — 5y
0
Did you parent the cakes? piRadians 297 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

OK, So I've had this problem too and the solution is honestly an error on Roblox's part. For some unexplainable reason, if you Clone() an object, if you don't specify what said Clone is being parented to it just straight up won't clone.

Now, I see the fact that you parented them, but you did it after referring to the Clones in the Duplicated section of the script (before you parented them)

I would say you should parent them to Workspace temporarily and then parent them where you want them.

-- Script in game.Workspace.Cake.smallCake
while true do
    wait(6)
    -- Variable Assignment
    local SmallCake = script.Parent
    local clonedSmall = SmallCake:Clone()
    local clonedSmall2 = SmallCake:Clone()
    local clonedSmall3 = SmallCake:Clone()
    local clonedSmall4 = SmallCake:Clone()

    -- Parent all Cloned SmallCakes
    clonedSmall.Parent = game.Workspace
    clonedSmall2.Parent = game.Workspace
    clonedSmall3.Parent = game.Workspace
    clonedSmall4.Parent = game.Workspace

    -- Destroy all Scripts under cloned SmallCakes
    local duplicated0 = clonedSmall:FindFirstChild("Script")
    duplicated0:Destroy()
    local duplicated1 = clonedSmall2:FindFirstChild("Script")
    duplicated1:Destroy()
    local duplicated2 = clonedSmall3:FindFirstChild("Script")
    duplicated2:Destroy()
    local duplicated3 = clonedSmall4:FindFirstChild("Script")
    duplicated3:Destroy()

    -- ClonedSmall
    clonedSmall.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall.Position = Vector3.new(266.242, 831.029, -230.982)

    -- ClonedSmall2
    clonedSmall2.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall2.Position = Vector3.new(266.242, 831.029, -230.982)

    -- ClonedSmall3
    clonedSmall3.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall3.Position = Vector3.new(266.242, 831.029, -230.982)

    -- ClonedSmall4
    clonedSmall4.Parent = game.Workspace.Cake.ClonedObjects
    clonedSmall4.Position = Vector3.new(266.242, 831.029, -230.982) 
end

Now, this may not work, so feel free to leave a comment if I'm wrong.

Ad

Answer this question