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

I'm having problems with prompts and purchase?

Asked by
Lacin1a 12
5 years ago

I currently have a script which prompts a purchase:

local plr = game.Players.LocalPlayer
local button = script.Parent
local MarketplaceService = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(plr, 6783022)
end)

And I have this script for checking:

while true do

local mpService = game:getService("MarketplaceService")


mpService.ProcessReceipt = function(purchaseInfo)
    local plr = game:getService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
    if purchaseInfo.ProductId == 6783022 then
    print("Hey")
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

wait(1)
end

But none of these are working

0
Are you trying to prompt a product or gamepass? MachoPiggies 526 — 5y
0
@MachoPiggies Yes I am Lacin1a 12 — 5y

1 answer

Log in to vote
0
Answered by
Lacin1a 12
5 years ago
Edited 5 years ago

Place in a script in ServerScriptService

local MarketplaceService = game:GetService("MarketplaceService")

local Players = game:GetService("Players")

local passId = 6783022 -- change this to your game pass ID.

local function onPlayerAdded(player)


    local hasPass = false

    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)

    if hasPass == true then

      -- Enter What You Want It To Do

    end

end

Players.PlayerAdded:Connect(onPlayerAdded)

Ad

Answer this question