How would I go about making a safe that saves the content for when you join a new game?

How would I go about making a safe that saves the content for when you join a new game? I want to do this but don’t know how to approve it.

3 Likes

Can you elaborate a bit more? What type of content are you trying to save?

Like, having a safe that you can put tools into, and leave the server, join a new one and those tools show up.

1 Like

So assuming from our last conversation about datastores that you never really understood what I was talking about…

The main idea is the same… Only a bit more complicated… Since this is not the place to give out free scripts, I aint going to write a hundred line script, but I’ll happily tell you how to do it

So you’ll want to have a folder in ServerStorage that has all tools in it that you can reference… You can just save the name of the current tools in the safe and once the player rejoins, it will get them from that folder…

A easy way to do this would be simply doing

local AllSafeContents - PathToSafeContents, whether you have it in a gui or what.. 
local DataStore = game:GetService("DataStoreService"):GetDataStore("Tools")

local list = {}

for i,v in pairs(AllSafeContents) do
     table.insert(list, v.Name)
end

DataStore:SetAsync(Plr.UserId, list)

Then once the player rejoins, just go and cycle through the table to get the items back…

game:GetService("Players").PlayerAdded:Connect(function(plr)
   local good, info = pcall(function()
      return DataStore:GetAsync(plr.UserId)
   end)
      if good then
         for i,v in pairs(info) do
            local tool = game:GetService("ServerStorage"):FindFirstChild(v)
               if tool then
                 --Parent the tools
            end
         end
      end
   end)
1 Like

Alright, but I mean like, a storage where I click the storage build, pops up with a little gui put items in the lil gui type of thing, and go on with it.

1 Like

Nevermind I think thats what this is.

Mhm, I only done the Main saving part, the gui would be done using local scripts and a lot of RemoteEvents…

Since I have no idea what type of set up you currently have, I am not going to be talking about it any beside what I already said about the Local scripts and remote events… Good luck with your project though!

Thank you so much :slight_smile: I will defiantly work hard on this.

1 Like

Actually, I have never tried datastore.

I’ll try to make a system for you.

Please, that would be wonderful, I may just be able to pay back for your time if successful.

May I introduce to you, DataStore2?

I use it to store tables and such in my game and I’ve found it has no issues. If you’d like I could give you an example of using it with tables?

1 Like

Hmm, I guess anything could help.

Honestly, at this point, im willing to pay someone for this system.

I’ll PM you my way. Not the best, but it works.