How can I make this script be able to award a player 50 points after the player has bought this??
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
print(player)
local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent
local productId = 20792308
buyButton.MouseButton1Click:connect(function()
MarketplaceService:PromptProductPurchase(player, productId)
end)
local MarketplaceService = Game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId)
wait(1)
player:FindFirstChild("leaderstats").Points = player:FindFirstChild("leaderstats").Points + 50
-- ...
-- use DataStore to record purchase
-- ...
return Enum.ProductPurchaseDecision.PurchaseGranted
end

2 comments
Using
FindFirstChildwithout error checking is stupid -- it misleads the reader into thinking you do error check, yet will your code will error anyway..leaderstatssuffices.Ok, so how do I fix it then. It still errors without it.