I have a saving script to save various things. I've looked through it multiple times and I can't tell why it won't work. Thanks in Advance!
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("-xBuckDatax-")
-- Making the saving inside a function it shortened your code by a bit.
local function Save(player)
local key = "Player_"..player.UserId
local save = {
["SeerBux"] = player.leaderstats["SeerBux"].Value,
["SpdWaitTime"] = player.WaitTime.WaitTimeSpd.Value,
["StrWaitTime"] = player.WaitTime.WaitTimeStr.Value
}
--saves their key and money to the data store
local success, err = pcall(function()
DataStore:SetAsync(key, save)
end)
if not success then
warn("Failed to over-write data"..tostring(err))
return
end
end
-- I made this a function so it can be called whenever
local function Load(player)
-- saves the player Id as key
local key = player.UserId
local moneyAlready
local success, err = pcall(function()
moneyAlready = DataStore:GetAsync(key)
end)
if not success then
warn("Failed to read data"..tostring(err))
return
end
if moneyAlready then
player.leaderstats.SeerBux.Value = moneyAlready.SeerBux
player.WaitTime.WaitTimeSpd.Value = moneyAlready.SpdWaitTime
player.WaitTime.WaitTimeStr.Value = moneyAlready.StrWaitTime
else
Save(player)
end
end
Players.PlayerAdded:Connect(Load)
Players.PlayerRemoving:Connect(Save)

4 comments
Did you give you stats values if a player is new?
I have a leaderboard and when the game launches if they have stats this script will edit the values of the default settings
in the Load function the key is the player's userid alone, but you set the table's key as "Player_"..player.UserId in the save function
thx