Is there any way to have player data save in files? Like you can select an empty file to begin saving your new stats by starting a new game or you can press on 'Load' and click on your previous game file to continue where you left off?
How to create different save files in a single game?
1 answer
You'll just have to name the DataStore a different name, like this:
local SaveFileOne = game:GetService('DataStoreService'):GetDataStore("savefile1")
local SaveFileTwo = game:GetService('DataStoreService'):GetDataStore("savefile2")
And do the tasks like you did the first one
SaveFileTwo:GetAsync(playerkey)
SaveFileTwo:SetAsync(playerkey,datatable)
EDIT:
If you want someone to have 2 save files:
Clicking the "Load Save File 1" Gui that you've made LOCAL SCRIPT:
local button = --where your button is
button.MouseButton1Click:Connect(function()
local EventOne = game:GetService("ReplicatedStorage").EventOne -make a "Remote Event" and put it in ReplicatedStorage. You can name it anything, i named it EventOne.
EventOne:FireServer() --the local script tells the server that the button was clicked
end)
SERVER SCRIPT: Do your GetAsync here for the first save file.
local SaveFileOne = game:GetService('DataStoreService'):GetDataStore("SaveFile1")
local EventOne = game:GetService("ReplicatedStorage").EventOne
EventOne.OnServerEvent:Connect(function(player) --fires when EventOne was fired to the server.
local playerkey = "player-"..player.userId
local SaveFiles = SaveFileOne:GetAsync(playerkey)
--the save files you want them to recover
end)
Clicking "Load Save File 2" gui that you made
LOCAL SCRIPT:
local button = --where your button is
button.MouseButton1Click:Connect(function()
local EventTwo = game:GetService("ReplicatedStorage").EventTwo -make another remote event
EventTwo:FireServer()
end)
SERVER SCRIPT:
Do your GetAsync here for the second save file.
local SaveFileTwo = game:GetService('DataStoreService'):GetDataStore("SaveFile2")
local EventTwo = game:GetService("ReplicatedStorage").EventTwo
EventTwo.OnServerEvent:Connect(function(player)
local playerkey = "player-"..player.userId
local SaveFiles = SaveFileTwo:GetAsync(playerkey)
--the save files you want them to recover
end)
11 comments
So how do I implement them into a Gui?
You'd have to fire RemoteEvents since the DataStore can only be accessed through Scripts and not LocalScripts. So fire a remote event when the gui is clicked in a local script, and then have the datastore in a server script.
And finally do I use the GetASync and SetASync when they click on the gui in the local script?
No, you should put the GetASync and SetAsync in the Server Script. The only thing the Gui should do is fire the event, and the server script should handle the data store.
But yet, do a GetSync event when the button is pressed, and it's usually only nessasary to save when the player leaves so the queue doesnt fill.
Well I'm kinda lost of what I'm doing now
I'll post an answer to try to help out, gimma a sec
Ok i edited my original answer
And will this like keep levels, exp, cash, and backpack inventory separated/cleared when I join a new game file and save the whole thing in that one game file unless starting on another game file?
Since I also have a character save/load on character position script that whenever they join in a game it’ll save where ever their at and it seems to work fine since it goes back to the spawn but I don’t think it saves it a lot in the file
I think that all depends on how you;re creating your save script. If your backpack, position, cash etc is located on SaveFile1, loading a GetAsync() from SaveFile2 will start you fresh in all your values. Changing SaveFile2 does not affect SaveFile1
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
you'll need data store, but yes
Yeah but I feel like a beginner in Data Store cause I know how to store Cash and Levels and stuff thats all