I decided I would add a "Volume" value to my data storages and that is what broke everything. Where the comment says "eerror", savedValueKOs is not nil and savedValueVolume is nil. I decided that there is no DataStore for Volume? If there isn't, how do I create a new one? Would appreciate any help thank you!
local DataStore = game:GetService("DataStoreService"):GetDataStore("KOs")
local DataStore2 = game:GetService("DataStoreService"):GetDataStore("Volume")
game.Players.PlayerAdded:connect(function(player)
local key = "Player_" .. player.UserId
local savedValueKOs = DataStore:GetAsync(key)
local savedValueVolume = DataStore2:GetAsync(key)
if savedValueKOs and savedValueVolume then -- eerror
--Save format: {points, coins}
player.leaderstats.KOs.Value = savedValueKOs[1]
player.Character.Volume.Value = savedValueVolume[1]
else
local KillsToSave = {player.leaderstats.KOs.Value}
DataStore:SetAsync(key, KillsToSave)
local VolumesToSave = {player.Character.Volume.Value}
DataStore:SetAsync(key,VolumesToSave)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local key = "Player_" .. player.UserId
--Save key: {points, coins}
local KillsToSave = {player.leaderstats.KOs.Value}
DataStore:SetAsync(key, KillsToSave)
local VolumesToSave = {player.Character.Volume.Value}
DataStore:SetAsync(key,VolumesToSave)
end)

4 comments
correct me if I'm wrong, but on line 20 and 33m you have "DataStore:SetAsync" when saving the Volume, which is your "KOs". Shouldn't it be like: DataStore2:SetAsync
How did I miss that I'll check it out soon thanks
^ Did it fix?
nope, but you helped me fix one part of the problem