Cloning frame template not working?

I’m trying to add a item frame template for each item in the shop, somehow the loop just creates a single frame yet when I add test print() it is looping the right amount of times, can’t seem to figure out what’s causing this behavior.

What I get:

Here’s the local script:

--MADE BY SCI_PUNK 2020
--Events
local playEvent = game.ReplicatedStorage.Remotes.Play
--Variables
local player = game.Players.LocalPlayer
local mainMenuFrame = script.Parent.MainMenu
local shopFrame = player.PlayerGui.GameGui.Shop
local status = game.ReplicatedStorage:WaitForChild("Status")
local topStatus = script.Parent.TopStatus
local shopDebounce = false
local shopItems = game.ReplicatedStorage.Items
local itemTemplate = game.ReplicatedStorage.Shop.Gui.ItemTemplate


topStatus.Text = status.Value


mainMenuFrame.Play.MouseButton1Click:Connect(function()
	
	playEvent:FireServer()
	mainMenuFrame.Visible = false
	topStatus.Visible = true
	
end)


player:WaitForChild("InMenu").Changed:Connect(function(value)
	if value == true then
		mainMenuFrame.Visible = true
		status.Value = ""
	end
end)



status:GetPropertyChangedSignal("Value"):Connect(function()
	topStatus.Text = status.Value
end)
----------------------------------------------------------------SHOP

player.PlayerGui.GameGui.Shop.Close.MouseButton1Click:Connect(function()
	shopFrame.Visible = false
	shopDebounce = false
end)

function createShopFrame(name,price,parent)
	print(name,price,parent.Name)
	local itemFrame = itemTemplate:Clone()
	itemFrame.ItemName.Text = name
	itemFrame.Buy.Text = price
	
	
	itemTemplate.Parent = parent
	
	return itemFrame
end

function setItemsForShop (shopFrame)
	for _, item in pairs(shopItems:GetChildren()) do
		local frame = createShopFrame(item.Name,item.Price.Value,shopFrame)
	end
end


shopFrame.Robux.MouseButton1Click:Connect(function()
	setItemsForShop(shopFrame.RobuxFrame)
end)
shopFrame.Coins.MouseButton1Click:Connect(function()
	setItemsForShop(shopFrame.CoinsFrame)
end)

workspace.Shop.Touched:Connect(function()
	
	if shopDebounce then return end
	player.PlayerGui.GameGui.Shop.Visible = true
	shopDebounce = true
	setItemsForShop(shopFrame.RobuxFrame)
	
end)

Well, you aren’t offsetting new frames. (They could all be ontop of eachother)

If that’s not the problem,
Maybe the itemTemplate has visible set to false?

If you’re not getting any new frames in explorer, if you aren’t getting an error, and its printing out every time. I have no idea.

Can you send screenshots of the explorer of the ShopUI, Items in replicatedStorage, and the properties window of the itemTemplate?

I have a UIGridLayout, they’re not cloning neither setting the properties I’m asking for in the function, I completely lost here since I’m not getting any error here are the pics:
image

I set up a print of the values and they are coming through just fine as you can see in the output.

Ok I found it.

I do this kind of thing all the time

local itemFrame = itemTemplate:Clone() -- itemFrame

itemTemplate.Parent = parent -- itemTemplate

It’s silly how these small problems can take a while to find.

2 Likes

Oh gods! thanks a lot! I feel so silly hahaha

1 Like