I have been practicing a lot of programming and right now I am doing datastores. I don't know what I am doing wrong but it won't save.
Here is my code:
local DSS = game:GetService("DataStoreService")
local ScoreSave = DSS:GetDataStore("ScoreSave")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Score = Instance.new("IntValue", leaderstats)
Score.Name = "Score"
Score.Value = 100
local SavedScored
local success, err = pcall(function()
SavedScored = ScoreSave:GetAsync(plr.UserId.."-Score")
end)
if success then
Score.Value = SavedScored
else
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, err = pcall(function()
ScoreSave:SetAsync(plr.UserId.."-Score", plr.leaderstats.Score.Value)
end)
if success then
print("Success")
else
warn(err)
end
end)
I hope you can find what I am doing wrong.

5 comments
Did you go to Alvin's tutorial?
https://www.youtube.com/watch?v=DkYupSBUpes here
he probably is
make sure api services are enabled
I did it mostly from prior knowledge and used the roblox api for guidance. And yes, my api services are enabled