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

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

-- 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!

3 comments

0

Did you anchor the cake?

0

is the SmallCake a Model or Part? Run the script and check workspace to see if the cakes spawned.

0

Did you parent the cakes?

1 answer

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.

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