Here's the code to load the stats:
local DataStore = game:GetService("DataStoreService"):GetDataStore("SurvivalsStorage") game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("IntValue", player) stats.Name = "leaderstats" local Survivals = Instance.new("IntValue" , stats) Survivals.Name = "Survivals" local Key = "user-"..player.userId local SaveWins = DataStore:GetAsync(Key) if SaveWins then --save format: Survivals.Value = SaveWins[1] else local ValuesToSave = {Survivals.Value} DataStore:SetAsync(Key, ValuesToSave) end end) game.Workspace.ChildAdded:connect(Findthenoob)
Here's the code that saves the stats:
local DataStore = game:GetService("DataStoreService"):GetDataStore("SurvivalsStorage") game.Players.PlayerRemoving:connect(function(player) local Key = "user-"..player.userId local ValuesToSave = {player.leaderstats.Survivals.Value} DataStore:SetAsync(Key, ValuesToSave) end)
Both are Server scripts in workspace
NOTE: I HAVE FILTERING ENABLED