Equip system question (tools)

Hello,

I have two questions

1: How would i make it where if you bought a tool with coins, it would know you bought and remembered it when you rejoined to give you the item?

Its very complicated. Its UI based and the tools are in a folder in server storage. Any help is appreciated. I have looked every where.

1 Like

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.

1 Like

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.

2 Likes

Is there any examples on the docs site you just linked for saving values? (sorry i am on mobile at the moment and thank you for that)

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.

2 Likes

Does this sound about right:

local script in buy button ui, that checks the value true in the player and gives the tool as normal.

server script in ServerScriptService, that when a player leaves, checks if the value is true and saves it as true

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)

Im still unable to make it work, could you maybe provide an example so i can understand more?

Yes, there are examples for the most important functions of a data store including setting and getting data.

2 Likes

Can you show us the script that you’ve made that’s not working?

1 Like

as of now its gone bc i didnt save my work when getting off studio. Ill be sure to check out the link here in a bit and try again. Thank you again!

1 Like

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”.

Data storage, save it to the server so when you rejoin it remembers that and equips it to your backpack or custom backpack.

One of my friends may be able to help me on this so for now im marking the most helpful as my solution, as it gives more of an idea of what to do.