I've been looking at this for an hour and can't seem to find why the datastore isn't saving. (At 0 every time I load)
local DataStore = game:GetService("DataStoreService"):GetDataStore("DS1")
game.Players.PlayerAdded:Connect(function(player)
print("Called")
local key = player.UserId
--
local Data = Instance.new("Folder", player)
Data.Name = "Data"
--Data
local Level = Instance.new("IntValue", Data)
Level.Name = "Level"
local Breathing = Instance.new("IntValue", Data)
Breathing.Name = "Breathing"
local ValuesToSave = {Level.Value, Breathing.Value}
local SavedValues = DataStore:GetAsync(key)
if SavedValues then
print("Set Levels")
Level.Value = SavedValues[1]
Breathing.Value = SavedValues[2]
else
DataStore:SetAsync(key,ValuesToSave)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ValuesToSave = {player.Data.Level.Value, player.Breathing.Level.Value}
DataStore:SetAsync(player.userId, ValuesToSave)
end)

2 comments
http://idownvotedbecau.se/nodebugging/ psst, player removing
I just added that before it was a while true script and every 10 seconds it would save. Still wasn't working.