I'm making a game and I wanted to have a shop where players can buy tools and weapons to use throughout the game. However, I soon realized that there would need to be a way to tell the game to give the player who purchased the weapon or tool for all of the places in the game. Before I had just made scripts to give a specific player a specific item and put it in every place. Now that I am expanding my game and planning on having lots of places this practice would become difficult because I would need to make the script for every tool/ weapon for every player who purchased the weapon in every place in the game and the whole thing get's too complicated and I spend more time than necessary giving players the items for the game only to have the game buggy, unpolished and overall unfinished because all my time and effort went into making every place work with every player. Another problem I will face is players purchasing tools and such from the shop and having to wait for me to upload each script into all the places in order to be able to use their new items. All that I need is a way to make a script tell the game what to do instead of only telling the place it's in what to do. If anyone here knows how I would be able to do this and share the information with me I would be very grateful. thanks to everyone who took the time to read this and everyone who may have any ideas on how I would overcome this problem.
How can I give a player an item in a multi-place game?
1 answer
The answer you are looking for is DataStores. I'll explain how this will be done, and I'll link the wiki. However, I will not do the script for you (unless necessary) because you need to learn. So what you want to do is have kind of another leaderstats, (not named leaderstats, but the exact same thing) - the new stats, let's call them "Weapons". Inside "Weapons", there are many BoolValues (or IntValues if they can have multiple of the same) each with the name of the tool. Now pay attention. Once the player purchases it through the shop, you would clone the weapon into their character and starter gear, simple, and then set the BoolValue to true or the IntValue to +1. Once they leave, you will have to save a table (read about tables here that includes all the Values of the children of weapons (I'll show you how that's done if you want). Once a player joins the game, you check if they have the chart (using GetAsync), and if they do then set the values of the children of weapons accordingly. Then give them their weapons if it is true (or if IntValue, give them 1 of the weapon that many times). read about datastores here -- You will need to understand SetAsync, GetAsync, and charts in order to make this work.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I found your problem. It's because you don't have any code. To create code go Insert > Script
Use DataStore to save what weapon they bought.