Hello, there is a method to save the players backpack when they quit, and load it when they join? Can you please explain me how? I'm new to scripting.
COMMUNITY QUESTION
Help to save players backpack?
1 answer
Usually, you would want to get a table of the objects inside the backpack, like so:
local player = script.Parent --This script is in StarterPlayerScripts
local character = player.Character
local backpackTools = player.Backpack:GetChildren()
local charParts = character:GetChildren()
for key,value in pairs (charParts) do
if values.isA("Tool") then
table.insert(backpackTools,1)
end
end
Then just simply insert these in a DataStore using a table.
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Datastores
@x3ooz Datastores can't save Instance(Tools, Part, ...), it only can save string and number.
I found a solution that very clever is get the table of tools in Player's Backpack. And then use JSONEncode function to convert the table to string and save the string. To convert it back, use JSONDecode. Credit to @Arsubia12 :) https://scriptinghelpers.org/questions/96542/can-someone-tell-me-how-do-i-use-tables-for-data-saving
Use data stores. Make a table containing all the players tools and save that table to the datastore and then make a folder containing all the potential tools that the player can have and force the script to clone every tools that the table that you saved has and put the cloned object to the player's backpack
You can't save table :b
@Block_manvn Saving a table would work perfectly fine. The method given in that link isn't necessary.
I never know that Datastore can saving a table before... The wiki sites is not really specific what Datastore can save.