So, In this case I have a screen GUI with a frame and a text button. You buy the developer product in game, and it gives you money for the game. I've been getting complaints that people are not receiving the money. I used it and it works perfectly fine and in the output theres no errors.

productId = 22952120 
amnt = 1000
local MarketplaceService = game:GetService("MarketplaceService")
function UsernameFromID(ID)
	if type(ID) ~= "number" then
	return
	end
	local sets = game:service("InsertService"):GetUserSets(ID)
	for k, v in next, sets do
		if v.Name == "My Models" then
			return v.CreatorName
		end
	end
end
function giveRewards(player)
			local thisplr = script.Parent.Parent.Parent.Parent.Parent
				local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local score = stats:findFirstChild("Money")
				if (score~=nil) then
					score.Value = score.Value + amnt
	return Enum.ProductPurcaseDecision.PurchaseGranted
				end
			end
			end

script.Parent.MouseButton1Down:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent, productId)
end)

4 comments

1

Do you have another script that controls the purchase? You've got two functions, but I don't see them being used anywhere.

0

The leaderstats

0

Thanks.