Im making a shop system with different types of content. (ex: backpacks, knives, etc)
This is what the explorer looks like while in game.
That is my script. I cant Just Delete all the children because there is a grid layout and a ui padding. Can anyone help me delete only the frames?
Should this work?
No, you need to format it like this
local function removeContent()
local items = itemsFrame:GetChildren()
for i = 1, #items do
if items[i]:IsA("Frame") then
items[i]:Destroy()
end
end
1 Like
for _, Child in ipairs(Parent:GetChildren()) do
if Child:IsA("Frame") then Child:Destroy() end
end
2 Likes
while itemsFrame:FindFirstChildWhichIsA("Frame") do
itemsFrame:FindFirstChildWhichIsA("Frame"):Destroy()
end
This may be a little better
local frame = itemsFrame:FindFirstChildWhichIsA("Frame")
while frame do
frame:Destroy()
frame = itemsFrame:FindFirstChildWhichIsA("Frame")
end
2 Likes
This is a fairly bad practice and should be avoided, you’re performing the same operation twice (when it isn’t necessary to do so).
2 Likes
Was thinking that after I posted it. A vairable solves the issue but overall not going to cause issues either way.
1 Like