How to make a purchase button disappear after purchase?

Hello!

I need some help with making my purchase button disappear once the player has purchased a tool. I know I can just set visible to false, but I want it to remain invisible even when the player leaves and rejoins. Can anyone help with this?

You can use DataStores to save that the item has been purchased and then when they join the game again check if it has been purchased and hide the button if needed

1 Like

So, I’d make a script in the purchase button checking if the tool is in the player’s backpack and if so, hide the button?

Yes that would work too but then make sure to save the player’s inventory and load it when they rejoin

1 Like

If you are using a Game pass, then you use MarketplaceService.PromptGamePassPurchaseFinished to check if they purchased a Gamepass, you would then check if they own the gamepass if they rejoin using MarketplaceService.UserOwnsGamePassAsync, which you can wrap this in a pcall for you to check if they own the Game pass.

WIth Developer Products, to check if an Item was actually purchased, you would be using MarketplaceService.ProcessReceipt which is a callback used for Detecting if a Product was Purchased

If you are using a Local Currency (as in your own inside the game), you can use a RemoteEvent to handle the data on a RemoteEvent and check the player has enough for what they are trying to buy, and give them ther item if they do.

For both Developer Products and Local Currency, they Require DataStoreService, Developer Products and be purchased for as many times as you want, and with Local Currency, all you are doing is changing a number in a game, which is why we save these numbers for later, if you save these numbers, and then Check the Players Data to see if they have it, you can then close the button.

1 Like

Theres no point in storing your purchase in a database hence theres methods in MarketPlaceService that check things like this

This isnt true,

You do this Primarly with Developer Products, and with Local Currency, Developer Products can be purcahses forever, and there is no limit to, thats why we save the Data so we can check later, so we dont purchase again.

You may think “then use a gamepass”, but this is really useful.

1 Like

Thats true, but if they make a custom shop they still need to save the data

perhaps in general if you want to receive the data of all of your purchases without needing to do it one by one which no one wants to do, but referring to what the user posted you wouldnt need to if hes just trying to do one simple check and im 100% sure he doesnt have a database setup for his purchases with a players data stored somewhere on backend for him to get.

Nope, you still need to save the Data,

  1. Its safer
  2. its more convienient

What I provided checks if a Event happens, which can be used to check if a Purchase was made or not, but if they want to keep it like that, they would need to save the Data, for when the player rejoins.

nope? you dont need to save anything. theres already methods that check if a player owns said asset.

Not for Developer Products, and Local Currenies, where have you been?

developer products aren’t gamepasses and are made to be purchased over and over? and im referring to what the person wants. i know ways on saving values to a key in a database lol i dont need to be reminded

also im well aware of this lol, thats why i specifically said asset