You’d save the name of the item the player bought (linked to the player’s user id) in a DataStore, load the DataStore up when the player rejoins, and copy the item from ServerStorage into the player’s inventory.
how would i make it save what you bought when you do buy it, instead of equip to save? i also do not know what this would look like in a script, could you possibly provide an example?
I don’t exactly know what your game is, so I’d be hesitant to provide you with an entire save system. If you mean that you want someone to save the item so that they keep it when they die, you could possibly set a value somewhere in their Player object confirming that they have the item and check that value when the player’s character respawns. If you mean that you would like the player’s items to save when they leave the game, there’s a good article about saving using DataStores here.
i didnt want an entire system, just an example. also, i have read over the article before making this topic and it only did seem to help a little bit. Thanks!
There are plenty of examples on @BitLang’s link, but here’s another one: https://create.roblox.com/docs/scripting/data/data-stores
I’ve done something using dataStores and UI recently, so I can help you with any questions you have about it. (Well, maybe not ANY, but most) What I would do, is I would make a folder in the player which has a BoolValue for each item. When the item is bought, you will change the bool value for that item, and when the player leaves the game, it will look at each boolValue, and it will save it in a dataStore. When the player joins back in, then you will have a script give the player all the items they have.
Use a datastore. You can look up a datastore tutorial on YouTube. Essentially, just make a key in a Datastore. Call it “ownsTool1_player” and add their userID on the end or something, and make it false on default. When they buy it, update that value to true. When they rejoin, use GetDataStoreAsync or some function like that to get that value "ownsTool1_player" + player.UserId. If it’s true, then clone the tool from replicatedstorage into the players inventory. Otherwise, do nothing.
No you don’t need a localscript for it. Just make a server script that makes a BoolValue in the player. Call the value “HasTool1” or something. Then detect when they click the button with a LOCAL script, set it to true. Detect when the player leaves on a server script, and then save that boolean with a unique key. When PlayerAdded (when they join back), use the getting function with datastores and make the value from the datastore into the value in the player. Check if it’s true, and if so, give the player the tool. (Clone it into their player.Backpack)
You could Save every tool in the Player’s backpack/Character
When the Player leaves store them into a table.
When the Player joins see if the stuff in the table is in the ServerStorage folder if it is then Clone it to the Player Backpack/Character (Backpack better)
Now if you have like a Bought UI Then you would check if the Player has the tool if he does then the text should be like “Bought”.