How can i make a script that add a leaderstats value called coins when a developer product with a certain id is purchased

local productFunctions = {}

function productFunctions.Bought(userId: number)

local plr = game.Players:GetPlayerByUserId(userId)

if plr then
	
	plr.leaderstats.Coins.Value += 1000
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
	
else
	return Enum.ProductPurchaseDecision.NotProcessedYet
end

end

return productFunctions