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)
On line 22, you're replacing the value of EXP everytime the player leaves with the EXP itself, and not the value that he EXP has.
local SaveTable = {Player.leaderstats.EXP.} --You did
Just do...
local SaveTable = {Player.leaderstats.EXP.Value} --"EXP.Value"
On line 22, you forgot to include the Value
local SaveTable = {Player.leaderstats.EXP.Value}