Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
xoxLua 0
4 years ago

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

Log in to vote
0
Answered by
xoxLua 0
4 years ago

Forgot to update ShopListChildren after i added new children.

Ad

Answer this question