I'm trying to store the player's level and xp for my RPG in DataStorage but something beyond my comprehension is happening
game.Players.PlayerAdded:connect(function(player)
repeat wait() until player.Character
--#load#--
local folder=Instance.new("Folder",player) folder.Name="Storage"
local level=Instance.new("IntValue",folder) level.Name="level" level.Value=1
local xp=Instance.new("IntValue",folder) xp.Name="xp" xp.Value=0
--==--
--#datastore#--
local DataStore=game:getService("DataStoreService"):GetDataStore("StatStore")
local key=("player-"..player.userId)
local savestats=DataStore:GetAsync(key)
if savestats then
print("Found "..player.Name.."'s save file! Loading...")
level.Value=savestats[1]
xp.Value=savestats[2]
print("Stats successfuly loaded!")
else
print("Making a new save for "..player.Name)
local statstosave={level.Value,xp.Value}
DataStore:GetAsync(key,statstosave)
print("Made "..statstosave[#statstosave].." things to save in DataStorage for "..player.Name)
end
--==--
i know, i know, i dont use spacing in my coding- sorry about that. anyway, it says: >"Making a new save for Qorm" then >"Made 0 new things to save in DataStorage for Qorm"
help would be appreciated!!

2 comments
Data persistence isn't reliable -.-
It works for me.