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

Problem with using for i, v in pairs to remove children. And Cloning a folder. Can someone help?

Im trying to that when i click on the item, it will show info on the right side. Click this for pic of GUI

Here is my code for shop GUI:

local ShopTemplates = script.ShopTemplates
local ShopInfoTmp = script.ShopInfo

local ShopTemplateChildren = ShopTemplates:GetChildren()
local ShopInfoChildrenTmp = ShopInfoTmp:GetChildren()

local ShopFrame = menuFrames.Shop
local ShopList = ShopFrame.Items
local ShopInfoChildren = menuFrames.Shop.ItemInfo:GetChildren()
local ShopListChildren = ShopFrame.Items:GetChildren()

for i, v in pairs(ShopTemplateChildren) do
	local itemClone = v:Clone()
	itemClone.Parent = ShopList
end
for index = 1, #ShopListChildren do
	local ListItem = ShopListChildren[index]
	if ListItem.Name ~= "UIListLayout" then
		ListItem.Button.MouseButton1Down:Connect(function()
			for i, v in pairs(ShopInfoChildren) do
				v:Destroy()
			end
			local infoFor = ShopInfoTmp[ListItem.Name]
			if infoFor then 
				local inforTmpClone = infoFor:Clone()
				inforTmpClone.Parent = ShopFrame.ItemInfo
			end
		end)
	end
end

But the MouseButton1Down Function dosent do anything. No errors either. It just does nothing. Can someone help me?

1 answer

Forgot to update ShopListChildren after i added new children.

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