Using GetAsync() to retrieve a variable value?

So I am currently trying to create a Data Store system that goes through a table and uses GetAsync() to retrieve the value of a player’s leaderboard stat. I’m doing this so that I don’t have to copy and paste lines of code whenever I want to add a new stat.

local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("SavedStats")
local rs = game:GetService("ReplicatedStorage")
local remotes = rs:WaitForChild("REs")
local currencyRemote = remotes:WaitForChild("CurrencyCounter")

local intStats = {"Money"}

game.Players.PlayerAdded:Connect(function(plr)
	local leaderB = Instance.new("Folder")
	leaderB.Name = "leaderstats"
	leaderB.Parent = plr
	
	for i,stat in pairs(intStats) do
		local addStat = Instance.new("IntValue")
		addStat.Name = stat
		addStat.Value = ds:GetAsync(plr.UserId):FindFirstChild(stat) or 0
		addStat.Parent = leaderB
	end
	
	currencyRemote:FireServer(plr)
	
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:SetAsync(plr.UserId, {
		["Money"] = plr.leaderstats.Money.Value;
	})
end)

Here is the error occurring in the Output:

And then I checked the Dev Console in game:

I’m really lost as to what I should do, I’ve done everything. I’ve checked multiple other topics and watched multiple videos on Data Stores and etc. I’m a returning scripter, so I haven’t done anything like this in a while.

local data = nil
local success, err = pcall(function()
	data = ds:GetAsync(plr.UserId)
end)
if not success then warn(err) return end
if data == nil then data = {} end
for i, stat in pairs(intStats) do
	local addStat = Instance.new("IntValue")
	addStat.Name = stat
	addStat.Value = data[stat] or 0
	addStat.Parent = leaderB
end

Intro to Dictionaries (roblox.com)

I am still getting the same error, but I will read up on the article you sent me. Thank you.

I have edited the reply, try now

The line error has gone away, but the API Services are still rejecting the request.

Enable studio api access in settings

Works like a charm! Do you know how I would go about doing the same thing but with SetAsync()?