KashTheKingYT

ShopControl Script

Jun 29th, 2023
2,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. local shopFrame = script.Parent
  2. local gui = shopFrame.Parent
  3. local button = gui.ShopButton
  4. local itemList = shopFrame:WaitForChild("ItemList")
  5. local preset = itemList:WaitForChild("Preset")
  6.  
  7. local marketplaceService = game:GetService("MarketplaceService")
  8. local replicatedStorage = game:GetService("ReplicatedStorage")
  9. local products = replicatedStorage:WaitForChild("Products")
  10.  
  11. local remote = replicatedStorage:WaitForChild("PurchaseProduct")
  12.  
  13. function purchase(assetId)
  14.     remote:FireServer(assetId)
  15. end
  16.  
  17. for i,product in products:GetChildren() do
  18.     local info = marketplaceService:GetProductInfo(product.Value,Enum.InfoType.Product)
  19.    
  20.     if info then       
  21.         local price = info.PriceInRobux
  22.         local name = info.Name
  23.         local isForSale = info.IsForSale
  24.         local image = info.IconImageAssetId
  25.        
  26.         if isForSale then
  27.             local newPreset = preset:Clone()
  28.             newPreset.Visible = true
  29.             newPreset.Product.Price.Text = "R$"..price
  30.             newPreset.Product.ItemName.Text = name
  31.             newPreset.Product.Icon.Image = "rbxassetid://"..image
  32.            
  33.             newPreset.Name = name
  34.             newPreset.Parent = itemList
  35.            
  36.             newPreset.Product.Purchase.MouseButton1Down:Connect(function()
  37.                 purchase(product.Value)
  38.             end)
  39.         end
  40.     end
  41. end
  42.  
  43. button.MouseButton1Down:Connect(function()
  44.     shopFrame.Visible = not shopFrame.Visible
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment