Hello all!
So recently, my datastore's started to return newly inputted values as "NIL" and I am not sure exactly as to why!
Any and all help is appreciated; I do not understand in the script that'd 'cause this problem, because everything's proper with the others as per the image.
Thank you!
image -- https://gyazo.com/267954161c2b15169e7862751ff8eee7
local DSS = game:GetService("DataStoreService")
local RepStorage = game:GetService("ReplicatedStorage")
local GuardianDataStore = DSS:GetDataStore("GuardiansDataStorage")--GuardiansDataStorage
local PlayerDataTemplate = {
--["Name"] = {"ValueObject", defaultValue},
["Gold"] = {"NumberValue", 1000},
["Level"] = {"NumberValue", 0},
["Wins"] = {"NumberValue", 0},
["Kills"] = {"NumberValue", 0},
["Diamonds"] = {"NumberValue", 0},
["Emeralds"] = {"NumberValue", 0},
["XP"] = {"NumberValue", 0},
--// Class Details \\--
["TacticianLevel"] = {"NumberValue", 0},
["TacticianXP"] = {"NumberValue", 0},
["KnightLevel"] = {"NumberValue", 0},
["KnightXP"] = {"NumberValue", 0},
["DemonLevel"] = {"NumberValue", 0},
["DemonXP"] = {"NumberValue", 0},
["CorsairLevel"] = {"NumberValue", 0},
["CorsairXP"] = {"NumberValue", 0},
--//chars\\--
["Ivan"] = {"BoolValue", false},
["Ragnoroc"] = {"BoolValue", false},
["Jake"] = {"BoolValue", true},
["Poleski"] = {"BoolValue", false},
["DeRetto"] = {"BoolValue", false},
["Bianca"] = {"BoolValue", false},
["Serge"] = {"BoolValue", false},
["Hektor"] = {"BoolValue", false},
["Akas"] = {"BoolValue", false},
["Bane"] = {"BoolValue", false},
["Splinter"] = {"BoolValue", false},
["Elsa"] = {"BoolValue", false},
["Doug"] = {"BoolValue", false},
["Blacksmith"] = {"BoolValue", false},
["HirateTadaoki"] = {"BoolValue", false},
--//weps\\--
["SwordC"] = {"BoolValue", false},
["SwordU"] = {"BoolValue", false},
["SwordR"] = {"BoolValue", false},
["SwordE"] = {"BoolValue", false},
["SwordL"] = {"BoolValue", false},
["AxeC"] = {"BoolValue", false},
["AxeU"] = {"BoolValue", false},
["AxeR"] = {"BoolValue", false},
["AxeE"] = {"BoolValue", false},
["AxeL"] = {"BoolValue", false},
["SpearC"] = {"BoolValue", false},
["SpearU"] = {"BoolValue", false},
["SpearR"] = {"BoolValue", false},
["SpearE"] = {"BoolValue", false},
["SpearL"] = {"BoolValue", false},
["ScytheC"] = {"BoolValue", false},
["ScytheU"] = {"BoolValue", false},
["ScytheR"] = {"BoolValue", false},
["ScytheE"] = {"BoolValue", false},
["ScytheL"] = {"BoolValue", false},
["DaggerC"] = {"BoolValue", false},
["DaggerU"] = {"BoolValue", false},
["DaggerR"] = {"BoolValue", false},
["DaggerE"] = {"BoolValue", false},
["DaggerL"] = {"BoolValue", false},
["MaceC"] = {"BoolValue", false},
["MaceU"] = {"BoolValue", false},
["MaceR"] = {"BoolValue", false},
["MaceE"] = {"BoolValue", false},
["MaceL"] = {"BoolValue", false},
["Silence"] = {"BoolValue", false},
["Duskbomb"] = {"BoolValue", false},
["Lightbane"] = {"BoolValue", false},
["Darkbane"] = {"BoolValue", false},
["Mirage"] = {"BoolValue", false},
["DeRettosDagger"] = {"BoolValue", false},
["Bazooka"] = {"BoolValue", false},
["Shotgun"] = {"BoolValue", false},
["Winterviel"] = {"BoolValue", false},
["SmithsHammer"] = {"BoolValue", false},
["Soulshard"] = {"BoolValue", false},
["VioletExecution"] = {"BoolValue", false},
["StarterDagger"] = {"BoolValue", true},
["Katana"] = {"BoolValue", false},
--// Used for Legendary Wep Upgrades \\--
["Hold"] = {"BoolValue", false},
["HoldA"] = {"BoolValue", false},
["HoldD"] = {"BoolValue", false},
["HoldSp"] = {"BoolValue", false},
["HoldSc"] = {"BoolValue", false},
["HoldM"] = {"BoolValue", false},
--// Extras \\--
["IvePlayedB4"] = {"BoolValue", false},
["StarterPackCoins"] = {"BoolValue", false},
--// Promo Codes \\--
["LAUNCHED"] = {"BoolValue", false},
--// Achievements \\--
["ReachedLevel100"] = {"BoolValue", false},
["Level150"] = {"BoolValue", false}
}
game.Players.PlayerAdded:Connect(function(player)
local playerKey = "Player-ID:"..player.UserId
--This can stay since it's no big deal:
local Bools = Instance.new("Folder", player)
Bools.Name = "Bools"
local stats = Instance.new("Folder",player)
stats.Name = "stats"
for name, object in pairs(PlayerDataTemplate) do
local newValue = Instance.new(object[1])
newValue.Name = name
newValue.Value = object[2]
if object[1] == "NumberValue" or object[1] == "StringValue" then
newValue.Parent = stats
else
newValue.Parent = Bools
end
end
local GetSave;
local success, message = pcall(function()
GetSave = GuardianDataStore:GetAsync(playerKey)
end)
if success then
--DataStore worked and retrieved something. We continue.
if GetSave then
for _, object in ipairs(Bools:GetChildren()) do
if object:IsA("BoolValue") then
print(object.Name, GetSave[object.Name])
object.Value = GetSave[object.Name]
end
end
for _, object in ipairs(stats:GetChildren()) do
if object:IsA("StringValue") or object:IsA("NumberValue") then
object.Value = GetSave[object.Name]
end
end
print("Data loaded for "..player.Name)
else
end
else
print("Problem loading data!")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerKey = "Player-ID:"..player.UserId
local Bools = player.Bools
local stats = player.stats
--the table we write to using our current player values
local tableToSave = {};
for _, object in ipairs(Bools:GetChildren()) do
if object:IsA("BoolValue") then
tableToSave[object.Name] = object.Value
end
end
for _, object in ipairs(stats:GetChildren()) do
if object:IsA("StringValue") or object:IsA("NumberValue") then
tableToSave[object.Name] = object.Value
end
end
local success, message = pcall(function()
GuardianDataStore:SetAsync(playerKey, tableToSave)
end)
if success then
if message then
print(message)
end
print("saved success for "..player.Name)
end
end)

2 comments
What and where do you mean by newly inputted values?
In the image it shows that "LAUNCHED" is the newly inputted boolean value. As in the dictionary it's ["LAUNCHED"] = {"BoolValue", false}, which is what it should be. But, in the output it says "nil" And no clue as to why as I set it to false in the scrpt, and the others work.