Dev Product Help

			if self.Instance.Custom.DevProduct.Value > 0 then
				if
					not MarketPlaceService:UserOwnsGamePassAsync(
						self.Tycoon.Owner.UserId,
						self.Instance.Custom.DevProduct.Value
					) and not skipDevProductCheck
				then
					MarketPlaceService:PromptProductPurchase(self.Tycoon.Owner, self.Instance.Custom.DevProduct.Value)
					RecentDevProductButton[self.Tycoon.Instance][self.Instance.Custom.DevProduct.Value] = self
					canBeBought = false
					playSound = false
				end
			end

I know it says MarketPlaceService:UserOwnsGamePassAsync is their anything similar to this for dev products?

2 Likes

Dev products can be purchased more than once, so Roblox does not keep track of this data for you. You can read about handling purchases here

I have read this article and still no luck with what I am trying to do…

Essentially you can give MarketplaceService a callback function that will be automatically called whenever a player purchases a Dev product.

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local userId = receiptInfo.PlayerId
    local productId = receiptInfo.ProductId
    
    -- handle purchase
end

This is all the help that Roblox provides you, but knowing the purchaser’s UserId and purchased productId, you can do the rest. (You can get the Player instance with game.Players:GetPlayerByUserId(userId))

From there, the documentation links to Data Stores, which you should then use to store that the player owns the product. There exist open source Datastore modules, such as Datastore2 that you could use to help make this process easier.

Okay I’ve got it to sorta work but every time I buy the product it gives me an error.

Content.Classes.Button:510: attempt to index number with 'WaitForChild'

The line that it’s talking about is

MarketPlaceService.PromptProductPurchaseFinished:Connect(function(plr, id, receiptInfo)
	if receiptInfo then
		if RecentDevProductButton[plr:WaitForChild("Tycoon").Value] then
			RecentDevProductButton[plr:WaitForChild("Tycoon").Value][id]:Buy(true, true)
		end
	end
end)

This is Printing with print(RecentGamepassButton)

image