I have been trying to make a script that saves/loads using Data Store.. I have made this so far...
local Store = game:GetService("DataStoreService"):GetDataStore("XP/LEVEL")
game.Players.PlayerAdded:connect(function (player)
local playername = player.Name
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
stats.Parent = player
local xp = Instance.new("IntValue")
local xpStats = Store:GetAsync(playername.."XP")
xp.Name = "XP"
xp.Value = xpStats or 0
xp.Parent = stats
local Level = Instance.new("IntValue")
local xpLevel = Store:GetAsync(playername.."LEVEL")
Level.Name = "Level"
Level.Value = xpLevel or 1
Level.Parent = stats
end)
game.Players.PlayerRemoving:connect(function (player)
local playername = player.Name
local XP = player.leaderstats:FindFirstChild("XP")
Store:SetAsync(playername.."XP",XP.Value)
local LEVEL = player.leaderstats:FindFirstChild("Level")
Store:SetAsync(playername.."LEVEL", LEVEL.Value)
end)
There is no errors in the output at all. But it just doesn't seem to want to work. Did i set up the "GetAsync" and "SetAsync" correctly?
