:Clone() not cloning children

I am trying to make a script that clones a frame, but when I clone it, none of the children get cloned with it.
Very sorry if I word things wrong, I have been trying this for what feels like forever.

Here’s the script:


local s = script.Parent
local Letters = {
	-- letter = {position, size}
	["A"] = { Vector2.new(0, 0), Vector2.new(8, 13)  },
	["B"] = { Vector2.new(9, 0), Vector2.new(8, 13)  },
	["C"] = { Vector2.new(18, 0), Vector2.new(8, 13) },
	["D"] = { Vector2.new(27, 0), Vector2.new(8, 13) },
	["E"] = { Vector2.new(36, 0), Vector2.new(8, 13) },
	["F"] = { Vector2.new(45, 0), Vector2.new(8, 13) },
	["G"] = { Vector2.new(54, 0), Vector2.new(8, 13) },
	["H"] = { Vector2.new(63, 0), Vector2.new(8, 13) },
	["I"] = { Vector2.new(72, 0), Vector2.new(8, 13) },
	["J"] = { Vector2.new(81, 0), Vector2.new(8, 13) },
	["K"] = { Vector2.new(90, 0), Vector2.new(8, 13) },
	["L"] = { Vector2.new(99, 0), Vector2.new(8, 13) },
	["M"] = { Vector2.new(108, 0), Vector2.new(8, 13) },
	["N"] = { Vector2.new(118, 0), Vector2.new(8, 13) },
	["O"] = { Vector2.new(127, 0), Vector2.new(8, 13) },
	["P"] = { Vector2.new(136, 0), Vector2.new(8, 13) },
	["Q"] = { Vector2.new(145, 0), Vector2.new(8, 13) },
	["R"] = { Vector2.new(154, 0), Vector2.new(8, 13) },
	["S"] = { Vector2.new(163, 0), Vector2.new(8, 13) },
	["T"] = { Vector2.new(172, 0), Vector2.new(8, 13) },
	["U"] = { Vector2.new(181, 0), Vector2.new(8, 13) },
	["V"] = { Vector2.new(90, 0), Vector2.new(8, 13) },
	["W"] = { Vector2.new(199, 0), Vector2.new(8, 13) },
	["X"] = { Vector2.new(209, 0), Vector2.new(8, 13) },
	["Y"] = { Vector2.new(218, 0), Vector2.new(8, 13) },
	["Z"] = { Vector2.new(227, 0), Vector2.new(8, 13) },
	["a"] = { Vector2.new(0, 15), Vector2.new(8, 13)  },
	["b"] = { Vector2.new(9, 15), Vector2.new(8, 13)  },
	["c"] = { Vector2.new(18, 15), Vector2.new(8, 13) },
	["d"] = { Vector2.new(27, 15), Vector2.new(8, 13) },
	["e"] = { Vector2.new(36, 15), Vector2.new(8, 13) },
	["f"] = { Vector2.new(45, 15), Vector2.new(8, 13) },
	["g"] = { Vector2.new(54, 15), Vector2.new(8, 13) },
	["h"] = { Vector2.new(63, 15), Vector2.new(8, 13) },
	["i"] = { Vector2.new(72, 15), Vector2.new(8, 13) },
	["j"] = { Vector2.new(81, 15), Vector2.new(8, 13) },
	["k"] = { Vector2.new(90, 15), Vector2.new(8, 13) },
	["l"] = { Vector2.new(99, 15), Vector2.new(8, 13) },
	["m"] = { Vector2.new(108, 15), Vector2.new(8, 13) },
	["n"] = { Vector2.new(118, 15), Vector2.new(8, 13) },
	["o"] = { Vector2.new(127, 15), Vector2.new(8, 13) },
	["p"] = { Vector2.new(136, 15), Vector2.new(8, 13) },
	["q"] = { Vector2.new(145, 15), Vector2.new(8, 13) },
	["r"] = { Vector2.new(154, 15), Vector2.new(8, 13) },
	["s"] = { Vector2.new(163, 15), Vector2.new(8, 13) },
	["t"] = { Vector2.new(172, 15), Vector2.new(8, 13) },
	["u"] = { Vector2.new(181, 15), Vector2.new(8, 13) },
	["v"] = { Vector2.new(191, 15), Vector2.new(8, 13) },
	["w"] = { Vector2.new(199, 15), Vector2.new(8, 13) },
	["x"] = { Vector2.new(209, 15), Vector2.new(8, 13) },
	["y"] = { Vector2.new(218, 15), Vector2.new(8, 13) },
	["z"] = { Vector2.new(227, 15), Vector2.new(8, 13) },
	[" "] = { Vector2.new(326, 15), Vector2.new(3, 13) },
	["1"] = { Vector2.new(236, 0), Vector2.new(8, 13) },
	["2"] = { Vector2.new(245, 0), Vector2.new(8, 13) },
	["3"] = { Vector2.new(254, 0), Vector2.new(8, 13) },
	["4"] = { Vector2.new(263, 0), Vector2.new(8, 13) },
	["5"] = { Vector2.new(272, 0), Vector2.new(8, 13) },
	["6"] = { Vector2.new(281, 0), Vector2.new(8, 13) },
	["7"] = { Vector2.new(290, 0), Vector2.new(8, 13) },
	["8"] = { Vector2.new(299, 0), Vector2.new(8, 13) },
	["9"] = { Vector2.new(308, 0), Vector2.new(8, 13) },
	["0"] = { Vector2.new(317, 0), Vector2.new(8, 13) },
	["!"] = { Vector2.new(324, 0), Vector2.new(8, 13) },
}
script.Parent.Visible = false
local function makeFrame()
	frame = Instance.new("Frame", script.Parent.Parent)
	frame.BackgroundTransparency = 1
	frame.Position = script.Parent.Position
	frame.Size = script.Parent.Size
	frame.AnchorPoint = script.Parent.AnchorPoint
	frame.SizeConstraint = script.Parent.SizeConstraint
	frame.ZIndex = script.Parent.ZIndex
	local list = Instance.new("UIListLayout", frame)
	list.FillDirection = Enum.FillDirection.Horizontal
	list.SortOrder = Enum.SortOrder.Name
end
makeFrame()
local function CreateLetter(ltr: string): ImageLabel?
	local ltrArray = Letters[ltr]
	if not ltrArray then
		return nil
	end

	local pos, siz = ltrArray[1], ltrArray[2]
	local letter = Instance.new("ImageLabel", frame)
	letter.Image = "rbxassetid://16769953402" -- sprite sheet here
	letter.ImageColor3 = script.Parent.TextColor3
	letter.ImageRectOffset = pos
	letter.ImageRectSize = siz
	letter.Size = UDim2.fromOffset(siz.X*2, siz.Y*2) 
	letter.BackgroundTransparency = 1
	letter.ResampleMode = Enum.ResamplerMode.Pixelated

	return letter
end

local function CreatePhrase(str: string): { ImageLabel? }
	local phrase = {}
	for i = 1, str:len() do
		local ltr = str:sub(i, i)
		local letter = CreateLetter(ltr)
		if letter then
			letter.LayoutOrder = i -- for the next step
			phrase[i] = letter
		end
	end
	return phrase
end

task.wait(1)

makeFrame()
CreatePhrase(script.Parent.Text)
task.wait()

local shadow = frame:Clone() -- <<<< the problem
shadow.Position += UDim2.new(0, 2, 0, 2)
local children = shadow:GetChildren()

for i = 1, #children do
	if children[i]:IsA("ImageLabel") then
		children[i].ImageColor3 = Color3.fromRGB(0,0,0)
	end
end

I’ve tried putting it in ReplicatedStorage, using WaitForChild, but nothing is working.
The only thing being cloned is the UIListLayout, which is defined when making the frame.

when you clone an object the parent is set to nil

you have to reparent it to somewhere you can see it

shadow.Parent = --something

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.