Advertisement
KashTheKingYT

Buy Product Script

Feb 28th, 2021
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local rs = game.ReplicatedStorage
  2. local gui = script.Parent
  3. local frame = gui.ItemFrame
  4. local items = frame.Items
  5. local openShop = gui.OpenShop
  6. local buyItem = game.ReplicatedStorage.BuyItem
  7. local itemsList = {
  8.     items.Item1,
  9.     items.Item2,
  10.     items.Item3,
  11.     items.Item4,
  12.     items.Item5,
  13.     items.Item6,
  14.     items.Item7,
  15.     items.Item8
  16. }
  17.  
  18. local function openShopF()
  19.     frame.Visible = not frame.Visible
  20. end
  21.  
  22. local function itemBuy(button)
  23.     buyItem:FireServer(button.ItemId.Value)
  24. end
  25.  
  26. for i,v in pairs(itemsList) do
  27.     if v:isA("TextButton") then
  28.         v.Activated:Connect(function()
  29.             itemBuy(v)
  30.         end)
  31.     end
  32. end
  33.  
  34. openShop.Activated:Connect(openShopF)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement