local dataStore = game:GetService("DataStoreService"):GetDataStore("DiceomathyData") local datst = game:GetService("DataStoreService"):GetDataStore("DiceomathyDataPoint") starterRolls = 0 --This is the starter money starterPoints = 0 game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local points = Instance.new("IntValue") points.Name = "Points" --Put ur currency name here, mine is Money points.Value = dataStore:GetAsync(plr.UserId) or starterPoints points.Parent = leaderstats local rolls = Instance.new("IntValue") rolls.Name = "Rolls" --Put ur currency name here, mine is Money rolls.Value = dataStore:GetAsync(plr.UserId) or starterRolls rolls.Parent = leaderstats end) game.Players.PlayerRemoving:Connect(function(plr) dataStore:SetAsync(plr.UserId, plr.leaderstats.Rolls.Value) end) game.Players.PlayerRemoving:Connect(function(plr) datst:SetAsync(plr.UserId, plr.leaderstats.Points.Value) end)
My script seems to be saving the data, but... not properly. When I add the points to let's say, 123, and rolls to 0. Then when I come back the points is now 0 and rolls is 0. I tried again with different values. 100 for points, 10 for rolls, when I rejoined my game, both values were 100. I would like a person out there to figure out how to get both values separately saved.
The reason why they are both the same value is that both saved values were saved in the exact same DataStore. When the data is retrieved, it will get the last value saved which in this case is the points. Consider using either 2 different datastores, or use 1 but save a table with the data.
Saving with a table:
dataStore:SetAsync(plr.UserId, {plr.leaderstats.Points.Value, plr.leaderstats.Rolls.Value})
Retrieving with a table:
local data = dataStore:GetAsync(plr.UserId) points.Value = data[1] rolls.Value = data[2]