How do I prompt game pass purchase only to users who haven't purchased yet?
Asked by
3 years ago Edited 3 years ago
Hey scriptinghelpers, just wondering how do I prompt a game pass purchase only to users who haven't purchased it yet? The code provided below is what I'm using, it work's even with the prompt purchase. I was wondering how I would prompt the game pass purchase only to users who have not purchased it yet? I have been referring to the MarketplaceService link https://developer.roblox.com/en-us/api-reference/class/MarketplaceService for help with this but, can't seem to find exactly what I'm looking for there so I thought I might as well ask for help. As I always say I'm only here to learn! Thank you for the help in advance, I appreciate it.
This is a Script inside of a Part inside of Workspace.
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 | local GamepassId = 17468467 |
05 | script.Parent.Touched:Connect( function (hit) |
06 | if debounce = = true and hit.Parent:FindFirstChild( "Humanoid" ) then |
07 | local character = hit.Parent |
08 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(character) |
09 | MarketplaceService:PromptGamePassPurchase(player, GamepassId) |
10 | if player and MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) and player.leaderstats.Tix.Value > = 666 then |
12 | local avatar = character:GetChildren() |
13 | for _,t in pairs (avatar) do |
14 | if t.ClassName = = "Part" then |
16 | fire.Color = Color 3. new( 1 , 0 , 0 ) |
17 | fire.SecondaryColor = Color 3. new( 0 , 0 , 0 ) |