Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GamePass LocalScript not show the PromptPurchase ?

Asked by 5 years ago

Hi, i have a problem with my gamepass, the message for prompt the GamePass not show.. I want this: https://goo.gl/images/tSKSZ9

My code (it's a LocalScript in StarterCharacterScripts)

local part = workspace.Boat.GamePass1
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 5111203 

part.Touched:Connect(function(hit)
    local function promptPurchase()

    local player = Players.LocalPlayer
    local hasPass = false

    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
    end)

    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end

    if hasPass == true then
        -- Player already owns the game pass; tell them somehow
    else
        -- Player does NOT own the game pass; prompt them to purchase
        MarketplaceService:PromptGamePassPurchase(player, gamePassID)
        end
    end
end)

what is the problem ?

1 answer

Log in to vote
0
Answered by
Syclya 224 Moderation Voter
5 years ago
Edited 5 years ago

local ID = 222; -- your gamepass id. local Workspace = game:GetService("Workspace") local Part = Workspace:WaitForChild("Boat"):WaitForChild("GamePass1") local Player = game:GetService("Players").LocalPlayer local Service = game:GetService("MarketplaceService") local UserHasPass = Service:UserOwnsGamePassAsync(Player.UserId, ID) if UserHasPass then script:Destroy() -- basically end the script if the user already has the game pass. return end Part.Touched:Connect(function() Service:PromptGamePassPurchase(Player, ID) end)

That should be it.

Ad

Answer this question