Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

DataStore not loading/saving leaderstats??

Asked by
Kulh 125
7 years ago
Edited 7 years ago

Here's the code to load the stats:

01local DataStore = game:GetService("DataStoreService"):GetDataStore("SurvivalsStorage")
02 
03game.Players.PlayerAdded:connect(function(player)
04 
05local stats = Instance.new("IntValue", player)
06stats.Name = "leaderstats"
07local Survivals = Instance.new("IntValue" , stats)
08Survivals.Name = "Survivals"
09 
10local Key = "user-"..player.userId
11 
12local SaveWins = DataStore:GetAsync(Key)
13 
14if SaveWins then
15    --save format:
View all 24 lines...

Here's the code that saves the stats:

01local DataStore = game:GetService("DataStoreService"):GetDataStore("SurvivalsStorage")
02 
03game.Players.PlayerRemoving:connect(function(player)
04 
05    local Key = "user-"..player.userId
06 
07    local ValuesToSave = {player.leaderstats.Survivals.Value}
08    DataStore:SetAsync(Key, ValuesToSave)
09 
10end)

Both are Server scripts in workspace

NOTE: I HAVE FILTERING ENABLED

0
Anyway i could fix this? Kulh 125 — 7y
0
??? Kulh 125 — 7y

Answer this question