Advertisement
Sungmingamerpro13

GamepassHandler(STORY GAME)

Nov 2nd, 2022
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local ModulesFolder = ReplicatedStorage:WaitForChild("Modules")
  3. local GamepassIdModule = require(ModulesFolder:WaitForChild("GamepassIds"))
  4. local MarketPlaceService = game:GetService("MarketplaceService")
  5.  
  6. local Players = game:GetService("Players")
  7. local player = Players.LocalPlayer
  8. local ShopFrame = script.Parent.GamepassFrame
  9. local ShopContainer = ShopFrame.ScrollingFrame
  10. local ShopButton = script.Parent.GamepassButton
  11.  
  12. for _, v in pairs(GamepassIdModule) do
  13. local GamepassIdInfos = MarketPlaceService:GetProductInfo(v, Enum.InfoType.GamePass)
  14.  
  15. local TemplateClone = ReplicatedStorage.Template:Clone()
  16. TemplateClone.Parent = ShopContainer
  17. TemplateClone.Visible = true
  18.  
  19. TemplateClone.GamepassIcon.Image = "rbxassetid://"..GamepassIdInfos.IconImageAssetId
  20. TemplateClone.PurchaseButton.Text = GamepassIdInfos.PriceInRobux
  21. TemplateClone.RobuxIcon.Image = "rbxassetid://4625635722"
  22.  
  23. if not MarketPlaceService:UserOwnsGamePassAsync(player.UserId, v) then
  24. TemplateClone.PurchaseButton.MouseButton1Click:Connect(function()
  25. MarketPlaceService:PromptGamePassPurchase(player, v)
  26. end)
  27. end
  28.  
  29. MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamepassId, Purchased)
  30. if GamepassId == v and Purchased then
  31. TemplateClone.PurchaseButton.Text = "OWNS"
  32. TemplateClone.RobuxIcon.Image = "rbxassetid://9207037475"
  33. end
  34. end)
  35. end
  36.  
  37. ShopButton.MouseButton1Click:Connect(function()
  38. ShopFrame.Visible = not ShopFrame.Visible
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement