Is there something like “MarketplaceService.PromptGamePassPurchaseFinished:Connect()” for Products?
You’ll want the ProcessReceipt method from the MarketplaceService.
There is technically a PromptProductPurchaseFinished event but it is deprecated. ProcessReceipt is the way to go.
That can’t be used on the client though
I can just make the server tell the client when their purchase was confirmed but I was just wondering if there’s something as convenient as PromptGamePassPurchaseFinished
Ah gotcha, glossed over that part in the title.
Yeah your best bet will probably be to just use a RemoteEvent with ProcessReceipt.
Yes there is! Here is a spinet of code that I used for a old game of mine
Guessing that you meant a gamepass
LOCAL SCRIPT
-- Variables
local btn = script.Parent
local plr = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local passID == 0 -- change to the pass ID
btn.MouseButton1Up:Connect(function()
-- does player have pass?
if plr.gamepasses.PassName.Value == 1 then --could also use MPS:UserHasGamepassAsync() but that only updates when the client joins, I make a saving folder in which when a pass is bought the value changes to 1, change PassName to the values name
-- pass stuff
else
MPS:PromptGamePassPurchase(plr, passID)
end
end)
MPS.PromptGamePassPurchaseFinished:Connect(function(plr, gamepassID, wasPurchased)
if wasPurchased and gamepassID == passID then
print("pass purchased! id: "..passID)
game.ReplicatedStorage.Events.GamepassBought:FireServer(passID) -- calls a remote event, used the passID because I use the same event for all passes.
end
end)
SERVER SCRIPT
eventsFolder.GamepassBought.OnServerEvent:Connect(function(plr, passID)
if passID == 0 then -- replace 0 with your passID
plr.gamepasses.PassName.Value = 1 -- change 'PassName' to the name of the value.
end
end)
We prompt the gamepass via a button if the player doesn’t own the pass then detect if the player bought it, if true then we call a Remote Event and change the passes value stored in the player to 1. You don’t have to make a folder with the gamepasses, but that’s how I do it.