local DataStoreService = game:GetService("DataStoreService"):GetDataStore("Experience")
game.Players.PlayerAdded:Connect(function(player)
local XP = script.Parent:WaitForChild("leaderstats").XP
local Level = script.Parent:WaitForChild("leaderstats").Level
local MaxXp = script.Parent:WaitForChild("leaderstats").XPMax
Level.Value = 0
XP.Value = 0
MaxXp.Value = 0
local key = "Player_" ..player.UserId
local SavedAsync = DataStoreService:GetAsync(key)
if SavedAsync then
XP.Value = SavedAsync[1]
Level.Value = SavedAsync[2]
MaxXp.Value = SavedAsync[3]
else
local ValueStore = {XP.Value, Level.Value, MaxXp.Value}
DataStoreService:SetAsync(key, ValueStore)
end
end)
I don't know why it isn't working, it don't print any error, can you help me? |