Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help to save players backpack?

Asked by 4 years ago
Edited 4 years ago

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.

0
Datastores 6zk8 95 — 4y
0
@x3ooz Datastores can't save Instance(Tools, Part, ...), it only can save string and number. Block_manvn 395 — 4y
0
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 Block_manvn 395 — 4y
0
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 DizzyGuy70 38 — 4y
View all comments (3 more)
0
You can't save table :b Block_manvn 395 — 4y
0
@Block_manvn Saving a table would work perfectly fine. The method given in that link isn't necessary. xPolarium 1388 — 4y
0
I never know that Datastore can saving a table before... The wiki sites is not really specific what Datastore can save. Block_manvn 395 — 4y

1 answer

Log in to vote
0
Answered by
Nckripted 580 Moderation Voter
4 years ago

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.

Ad

Answer this question