I want to save the players exp and level but it’s not working and it doesn’t show any warning massage not even in script analysis. Help ?
local PlayerId = "Player_"..Player.UserId
--LoadData
local data = {Exp.Value, Level.Value}
local success, errormassage = pcall(function()
data = ExpDataStore:GetAsync(PlayerId)
end)
if success then
if data then
Exp.Value = data.Exp
Level.Value = data.Level
-- Set out data equal to the current exp
end
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local PlayerId = "Player_"..Player.UserId
local data = {
Exp = Player.leaderstats.Exp.Value;
Level = Player.leaderstats.Level.Value;
}
local success, errormassage = pcall(function()
ExpDataStore:SetAsync(PlayerId, data)
end)
if success then
print("Data Saved")
else
print("Error saving data")
warn(errormassage)
end
end)```