Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm having problems with prompts and purchase?

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

2 comments

0

Are you trying to prompt a product or gamepass?

0

@MachoPiggies Yes I am

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.