I am having problems saving a player’s purchase history in a datastore so that the next time they load into the game, the shop will only give the player one option, which is to Equip the item. The problem here is that whenever the player buys the item and then leaves the game, and then when they rejoin, the shop sets the shop’s textbutton’s text to “Buy” again instead of “Equip” since they already bought the item in the last session.
My idea on how to fix this is to store a boolean value in a Datastore so that if it is set to true, then the Shop Button’s Text will be “Equip” whenever the player leaves and rejoins the game again. Then, if the bool value is set to false, the Shop Button’s Text will be left as “Buy”.
If someone can tell me how to do this, as many of the tutorials online only show how to set up datastores for leaderstats.
Thanks!
How do you know the player owns the item? Have you seen the data after you retrieved it in the second session? Can I see the data you retrieved if you have it already?
The 2 arrows are pointing to the boolean values I plan on storing in a datastore. Basically, the idea behind this is that if the player has bought the trail during this specific playing session, the bool value will equate to true and since this is being stored in a datastore, the next time the player leaves and rejoins the game, the true value of the bool will be set to true, and this in turn will automatically change the Buy button to the Equip button in their next playing session, and the one after, and so on. The player will have the option to Equip and Unequip the trail, and they won’t be able to buy it again since the Buy button will not show up unless the bool value is set to false.
Oh so you haven’t made a data store for it yet, My apologies i thought you had. so your question is best way to store this information?
Yes, and how to set up the datastore to store a boolean variable, since most tutorials online only showcase how to store leaderstats in a datastore.
Here is a method of making datastores that would be a great start for you Roblox Creator Documentation
After you’ve made your datastore module you would add additional functions just for storing these purchased items although I don’t recommend storing a bool each time
if you stored a bool the easiest thing to do would make a large table of items you will have in your game and have em all set to false and when the player brought them you would set them to true (then you’d need to make a function to add new items)
But what I recommend is just storing the item(Names or CustomIDs[ I highly recommend ]) themselves then checking if they own the item via indexing their inventory
I would recommended just checking if the player has the gamepass instead of going through the hefty process your talking about
Oh it’s not a gamepass, it’s actually an in game currency that players earn and use to buy trails.
What is the issue your facing?
Basically, whenever I buy the trail with my in game currency, it allows me to equip the trail. But then, when I leave and rejoin, I have to re-buy the trail again even though I already bought the trail in my last playing session.
You want to create a datastore to save the trails. There are multiple methods you are able to do to save the trails. The most efficient way is to create a table connecting the trail names to their own unique IDs. The reason we do this instead of just saving based on the trail name is cause you never know when you want to change the name of the trail. There are multiple posts about how to make a datastore on the forums.
Alright, I’ll look into it. Thanks! Do you have any good posts that you recommend?
I guess you would have to browse along and try and find things relevant.
Do you know how to solve this database error?