• Register a free account to view all forum content. Click here to create your own account.

How to save data not in leaderstats?

Joined
May 25, 2018
Messages
18
Ratings
1
Roblox
Singetail246
So is there a good tutorial I can watch/read on how to save data for players? I got this script from the workshop that saves values in the leaderstats but I don't really understand how it all works so I can't modify it to save values not in leaderstats, such as stuff bought in a shop, inventory items, etc.

Thanks in advance!
 

Ike

Member
Joined
Mar 11, 2018
Messages
84
Ratings
12
Roblox
imepic457
Discord
Ike#1888
Maybe have the data in a different folder in the player and change where the leaderstats is in the script to the folder
 
Joined
May 25, 2018
Messages
18
Ratings
1
Roblox
Singetail246
Not sure what you mean by "change where the leaderstats is in the script to the folder". Not sure what you mean there.

I have a script in the workplace that creates all the variables in either the player or leaderstats, which is in player.

The code I use to save the variables is the following (I have this script placed in the workspace):

game.Players.PlayerRemoving:connect(function(p)
if p:findFirstChild("leaderstats") then
p:SaveInstance("SavedStatPNum"..tostring(game.PlaceId),p.leaderstats)
end
end)
game.Players.PlayerAdded:connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("leaderstats") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("leaderstats") and pcall(function() Loaded = p:LoadInstance("SavedStatPNum"..tostring(game.PlaceId)) end) then
for j, v in pairs(Loaded:GetChildren()) do
pcall(function() p.leaderstats[v.Name].Value = v.Value end)
end
end
end)

It only saves the values in leaderstats, not the values in the player itself.
 

Ike

Member
Joined
Mar 11, 2018
Messages
84
Ratings
12
Roblox
imepic457
Discord
Ike#1888
Let's say you have a folder called "Data" (in Player) and you want to save to that folder, so instead of p.leaderstats do p.Data, that's what i meant.
 
Joined
May 25, 2018
Messages
18
Ratings
1
Roblox
Singetail246
so I create a folder called data. Inside the folder I have the variables I want to save. and then in the code I shared above, replace every "leaderstats" to "data"? is that what you mean?