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

How would you determine if a player has bought something?

I'm sorry if this is a stupid question.

I'm adding in a gamepass shop in-game for this tycoon I am developing for, and the owner has asked me to make it so if they buy the gamepass in-game then they get what they paid for without having to leave and rejoin.

for i,v in ipairs(script.Parent:WaitForChild("Gamepasses"):GetChildren()) do
		v:FindFirstChild("TextButton").MouseButton1Click:connect(function()
			if v.Name == "TwentyFiveKCash" then
				MarketplaceService:PromptPurchase(Player,TwentyFiveKPass)

Here is part of the code which prompts the user with a purchase. How would I determine whether or not the Player actually purchased the item?

2 comments

0

You could wait a couple of seconds and then see if the player has the pass by using the PlayerHasPass function

0

i think u can use PlayerOwnsAsset() for live results, idk, i think it might be better.

1 answer

✓ Accepted answer

The 'MarketplaceService' has an event called PromptPurchaseFinished which will ' Fires when a purchase is either denied or accepted. '.

This will allow you to check for the purchase, it provides the following args :- the player, the assed id and weather or not the purchase was successful or declined.

Hope this helps.

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