:Clone() Not working on Image Button

:Clone() Not working on Image Button
my code:

PlayerGui.MainUI.HotbarDisplay:WaitForChild("Template"):Clone()

Are you Parenting the Object?

1 Like

No, Im just trying to clone it
my full code:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
local SlotsUsed = {
	[1] = false,
	[2] = false,
	[3] = false,
	[4] = false,
	[5] = false,
	[6] = false,
	[7] = false,
	[8] = false,
	[9] = false,
	[10] = false
}
function AddToInventory(ItemIcon)
	local HotTemp = PlayerGui.MainUI.HotbarDisplay:WaitForChild("Template"):Clone()
	HotTemp.Icon.Image = "rbxassetid://"..ItemIcon
	for i=1, #SlotsUsed do
		if SlotsUsed[i] == true then
			HotTemp.Number.Text = i
		end
	end
	print("hrtr")
	HotTemp.Visible = true
end

game.ReplicatedStorage.Events.HotSwap.OnClientEvent:Connect(function(ItemIcon)
	AddToInventory(ItemIcon)
end)

Yeah, you parent the Clone, Otherwise it wont appear

When Cloning an Object, The Said clone doesn’t have a Parent, you need to set its Parent to where you want it to be.

local newclone = PlayerGui.MainUI.HotbarDisplay:WaitForChild("Template"):Clone()
newclone.Parent = PlayerGui.MainUI.HotbarDisplay.Template.Parent

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