Hello! I was wondering if there’s any posts related to this and I was wondering how I could make one for myself. Basically, I want to make it so that when a purchase prompt is activated, sort of a background effect appears. You can take a look at pet simulator 99, it sort of does exactly what I need:
You can use MarketPlaceService:PromptGamePassPurchase()
and MarketPlaceService.PromptGamePassPurchaseFinished
to check if the player has bought the gamepass. Heres an example:
local MPS = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local ID = 111111--Your ID
local Button = script.Parent--Your Button
--Put into a button event
Button.MouseButton1Click:Connect(function()
MPS:PromptGamePassPurchase(Player, ID)
--Open UI
end)
MPS.PromptGamePassPurchaseFinished:Connect(function(plr, gamepassID, wasPurchased)
if plr and gamepassID == ID and wasPurchased then
--If bought
end
if not wasPurchased then
--Close UI
print("Player did not purchase")
return
end
end)
Appologies for the late response, what would I do if I wanted the animation to happen with every prompt purchases, not a specific ID?
maybe you could try adding a module script containing all the ID’s?
I guess so thanks 033030303030
You can just remove these lines
if plr and gamepassID == ID and wasPurchased then
--If bought
end
I believe the reason they were added is to show a different message for each gamepass.
So something like this (edited version of @JAcoboiskaka1121’s answer)
MPS.PromptGamePassPurchaseFinished:Connect(function(plr, gamepassID, wasPurchased)
if wasPurchased then
print("Player purchased")
else
print("Player did not purchase")
end
end)
I added them so you can add logic to each gamepass, if you buy 1000 coins you can add some lines that do that. But I guess that’s not what he wanted.
Make a module of all your IDs and use a for loop to loop through them and connect a MarketPlaceService.PromptGamePassPurchasedFinished
event. Same thing for your buttons.