I'm making a shop GUI so players can buy swords and weapons. But an error appeared on the output saying "attempt to index number with 'MouseButton1Click'". and I tried everything that I could think of to fix this and it still doesn't work. I've tried finding online solutions but nothing helped. So I came here. Here's where I got the error:
box.MouseButton1Click:Connect(function()--Where I got the error for _, v in pairs(itemViewport:GetChildren()) do if not v:IsA("Frame") then v:Destroy() end end end)
What is box? you need to tell what the box is like is it a script.parent or script.parent.parent.box you might need to put the script as a local script and/or put the script inside the GUI Is it a part? if it's a part then you need to do
script.Parent.MouseClick:Connect(function() for _, v in pairs(itemViewport:GetChildren()) do if not v:IsA("Frame") then v:Destroy() end end end)
you need to put it in the local script in the part