I made this datastore script but it wont save my data!
local LevelDataStore = game:GetService("DataStoreService"):GetDataStore('Level')
game.Players.PlayerAdded:connect(function(Player)
local key = 'id-'..Player.userId
local leaderstats = Instance.new("IntValue", Player)
local exp = Instance.new("IntValue", leaderstats)
leaderstats.Name = "leaderstats"
exp.Name = "EXP"
local SaveAsync = LevelDataStore:GetAsync(key)
if SaveAsync then
exp.Value = SaveAsync[1]
else
local ThingsToSave = {exp.Value}
LevelDataStore:GetAsync(key, ThingsToSave)
end
end)
game.Players.PlayerRemoving:connect(function(Player)
local key = 'id-'..Player.userId
local SaveTable = {Player.leaderstats.EXP}
LevelDataStore:SetAsync(key, SaveTable)
end)

1 comment
You should really describe some more if you want more rep lol