I made this shop script, but it doesn't work. Nothing in the output or script analysis.
items = script.Parent.Frame:GetChildren() for i = 1, #items do function buy() local item1 = items[i]:FindFirstChild("Item1") local item2 = items[i]:FindFirstChild("Item2") local item3 = items[i]:FindFirstChild("Item3") local item4 = items[i]:FindFirstChild("Item4") local item5 = items[i]:FindFirstChild("Item5") local Cash = script.Parent.Parent.Parent.Parent.leaderstats:FindFirstChild("Gold") if item1 then if script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item1.Value).Value > items [i].item1Price.Value then script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item1.Value).Value = script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item1.Value).Value - items [i].item1Price.Value local buyitem = game.Lighting:FindFirstChild(items[i].ItemName.Value):Clone() end end if item2 then if script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item2.Value).Value > items [i].item2Price.Value then script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item2.Value).Value = script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item2.Value).Value - items [i].item2Price.Value end end if item3 then if script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item3.Value).Value > items [i].item3Price.Value then script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item3.Value).Value = script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item3.Value).Value - items [i].item3Price.Value end end if item4 then if script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item4.Value).Value > items [i].item4Price.Value then script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item4.Value).Value = script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item4.Value).Value - items [i].item4Price.Value end end if item5 then if script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item5.Value).Value > items [i].item5Price.Value then script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item5.Value).Value = script.Parent.Parent.Parent.Parent.Materials:FindFirstChild(item5.Value).Value - items [i].item5Price.Value end end if Cash.Value >= items[i].Cost.Value then Cash.Value = Cash.Value - items[i].Cost.Value local tool1 = game.ReplicatedStorage:FindFirstChild (script.Parent.Folder.Value):FindFirstChild(items[i].ItemName.Value):Clone() local tool2 = game.ReplicatedStorage:FindFirstChild (script.Parent.Folder.Value):FindFirstChild(items[i].ItemName.Value):Clone() tool1.Parent = script.Parent.Parent.Parent.Parent.Backpack tool2.Parent = script.Parent.Parent.Parent.Parent.StarterGear print("Purchase successful.") end items[i].BuyButton.MouseButton1Click:connect(buy) end end