If I’m understanding you correctly, you’re trying to get an event that fires every time a user in your game purchases ANY gamepass that’s not from your game? Or is it something else?
By “executed” do you mean processed or prompted? If you’re processing it locally, that’s not very secure & you should instead be using a server script that then subsequently fires to a local script when the purchase is processed
There’s an event for MarketplaceService that fires when a 3rd-party purchase is made.
It’s known as “ThirdPartyPurchaseFinished”
Is this what you’re looking for?
Witch that I mean it’s beaing prompted in a LocalScript
Yeah thank you very much, I’ll test it later, I’ll mark this as solved
Ah that’s my mistake. I just checked the documentation and apparently the event can only be executed through the command bar. Give me a moment to find a solution.
Ok there is no an event specifically for a third party purchase sale.
But I have an idea of a workaround.
You could check if the purchase isn’t a purchase from the game your player by it’s ID.
This is what I mean:
local MarketplaceService = game:GetService("MarketplaceService")
local gameDevProductIds = {000000, 000000, 000000} -- Put all the developer product IDs from YOUR game here
MarketplaceService.PromptPurchaseFinished:Connect(function(player, productId, isPurchased) -- The Event used for product purchases
if isPurchased then -- if a purchase was made
if not table.find(gameDevProductIds, productId) then -- and the product purchased is not one a developer product from your game then
print("A third party purchase was made by"..player)
end
end
end)
What would happen if I didn’t check if it was a purchase from my game? Hope you know what I mean
Either way, the event would fire when someone makes a developer product purchase, but in order to execute a certain piece of code only for third-party purchases when the event fires, you’ll need to add a check like I did above.
That’s what I’m assuming pls donate
did.
local MarketplaceService = game:GetService("MarketplaceService")
local gameDevProductIds = {000000, 000000, 000000}
MarketplaceService.PromptPurchaseFinished:Connect(function(player, productId, isPurchased) -- This event will still fire
if isPurchased then
if not table.find(gameDevProductIds, productId) then -- but this check will only execute the code below if its not a developer product in your game
print("A third party purchase was made by "..player)
-- Code you want to execute when someone makes a third party purchase
end
else
print("A product purchase was made by "..player.." that's NOT a third-party purchase")
end
end)
Would’t that also work without the table.find thing?