hi! I’m currently making a game and I’ve made a coin system where you can purchase items (tools) however whenever I leave the game and join back they never stay in my inventory? I was wondering if anyone could help with this because I’ve tried searching absolutely everywhere for a simple script to fix this but I can’t seem to find any anywhere. Thank you so much : )
If you searched probably about DataStore, you would easily find a solution.
You are unable to save instances, but you can store tables.
I recommend saving a table with the names of all the tools to the player when they leave, and when the player joins you should get that table you saved. Then use a for loop to go through that table and find the tools from a folder with the same name. Once you get the tool, clone it into the player’s backpack.
Example of finding tools from table:
for i, v in pairs(savedTable) do -- looping through all of the saved items
local tool = game.ServerStorage.AllTools[v] -- finding the tool with the same name
if tool then -- checking if the tool is really there
tool:Clone().Parent = plr.Backpack -- put the tool in the player's backpack
end
end
This is all assuming you’re trying to save the tools lol