Function inside playeradded function not changing leaderstats

This does not change the leaderstats. The developer product does successfully purchase. The reason why this is a function inside a function is that I need a way to find the player from the server. This does not give an error. The only problem with this is that it does not change the leaderstats. The prompt for the developer product is inside a part, this script is in ServerScriptService. Both are server scripts.

local MarketplaceService = game:GetService("MarketplaceService")

local devProductRewards = {
	[1261860735] = { Reward = 100 },
	[1261860764] = { Reward = 250 }
}


game.Players.PlayerAdded:Connect(function(player)
	local function processReceipt(receiptInfo)
		local boughtProductInfo = devProductRewards[receiptInfo.ProductId] --This is where you get info from the table
		print(boughtProductInfo.Reward) --Should print reward, if the id was found in the table.
		player.leaderstats.Coins += boughtProductInfo.Reward
	end
end)

this will not work as expected even if you get that to run inside .PlayerAdded

you should use the player’s ID from the receipt to figure out which player to work with
there’s an example on the developer.roblox.com page for ProcessReceipt