Still have questions? Join our Discord server and get real time help.
0

How do I use Dev products? [closed]

lucas4114 607
3 years ago

How do I use them? I did look at the wiki, but it was too confusing....

0
Did you just glance at the wiki or actually look and read? theawesome624 100 — 3y
0
I actually read it, I don't understand the "ProcessReceipt" and why I need 2 scripts to use them... lucas4114 607 — 3y

Locked by WideSteal321, clc02, and Azarth

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

10
M39a9am3R 3152
3 years ago
Edited 3 years ago

So, you want to learn how to use Developer Products? Great! First off, these things are a pain in the neck if you get something wrong. If you break your script along the road, you might even be held responsible for scamming if a user reports it and you never provided the product.

Creating the Developer Product

So to start off, you will need to make the developer product. So you want to go to Develop, Places, then hit under the gear icon Configure. You would want to go to Developer Products in the Configure screen and hit Create new. Type in the name, description, price, and upload an image. Now hit create and your screen should look more like this image.

Setting Up the Developer Product in Your Game

The Local Script

The Local Script is easy to set up, you can have the product prompt show up every time the player hits a button, or every time a player respawns.

So for my example, I will be using a local script and have the script detect if the player is hitting a Gui button.

script.Parent.DeveloperProductButton.MouseButton1Click:connect(function() --Here we establish the function that will fire everytime a the player hits the button.
game:GetService('MarketplaceService'):PromptProductPurchase( --We're now telling MarketplaceService to get a Product ready for us.
game.Players.LocalPlayer, --Required argument, you need the player instance.
123456789, --Remember that developer product you set up? In the left column you will see the Product Id. This is required for the second argument.
false, --This is the equip if purchased argument, however it will not work since the property only has affect on gears. So set this to true or false however you'd like it.
Enum.CurrencyType.Default --This will allow the developer to send a Developer Product prompt of Tickets, or Robux. However the Default will be Robux over Tickets if you have the Robux price set.
)
end)


Due to recent site updates, CurrencyType no longer holds purpose in this function. All transactions are Robux or Free. Tickets have been discontinued.

Now that we have the developer product purchase prompt set up, let's get into the server side of these scripts.

The Server Sided Script

For this part, you will want a regular script. This is the most important step in the Developer Product process. It is up to the developer (owner of the game) to handle and record the purchase using the ProcessReceipt function. ProcessReceipt is a callback function, so we'll need to return a result to supposedly the ROBLOX servers eventually. What ProcessReceipt will do is provide you with a dictionary of information. What a dictionary is, is basically a glorified table.

You will be given the following information with the ProcessReceipt table.

• PlayerId (number) - Id of the player who made the purchase.
• PlaceIdWherePruchased (number) - Specific place where the purchase was made (I do not know the reason for this property, probably for use in Universes).
• PurchaseId (string) - Unique identifier for the purchase which should be used to prevent granting an item multiple times for one purchase (Basically a mix of random numbers and letters to prevent the scripts from granting an item more than once).
• ProductId (number) - ID of the product purchased (Great for a place with multiple Developer Products, you will need to identify what the player bought).
• CurrencyType (CurrencyType Enum) - Just used to detect how the player bought it, with Robux or Tickets.
• CurrencySpent (number) - How much of that CurrencyType the user used.

So now, let's say I want to give 1,000 points to a person in the leaderboard with my script.

local DataStore = game:GetService("DataStoreService"):GetDataStore("ProductPurchases") --This will be where we keep track of pruchase records.

game:GetService("MarketplaceService").ProcessReceipt = function(ReceiptInfo) --ReceiptInfo will be our dictionary.
local Purchasing_Player = game.Players:GetPlayerByUserId(ReceiptInfo.PlayerId) --This will grab the Player based on the UserId. Yea! No more looping to find them!

--Since this is a test script, I will make sure the player pruchased Developer Product Id 123456789
if ReceiptInfo.ProductId == 123456789 then
--At this point we can award the player the 1000 points and record it in DataStore.
end
end

--Awarded the points, now it is up to us to record them.
DataStore:IncrementAsync(ReceiptInfo.PlayerId .. '_' .. ReceiptInfo.ProductId, 1)

--Now this is the most important. It will tell ROBLOX's servers you did everything you needed and tell them, hey he's done we can stop awarding him.
--If you do not add Enum.ProductPurchaseDecision.PurchaseGranted, then the player will receive the product each time they enter the game since it defaults to NotGrantedYet.
return Enum.ProductPurchaseDecision.PurchaseGranted
end


Conclusion

Hopefully I made this as quick and painless as I can. If I missed anything or if you have any questions feel free to post them in the comments below. If this answered your question, then do not forget to hit the Accept Answer button.

0
You need to configure the game, not the place. ChemicalHex 954 — 3y
0
So 'ProcessReceipt' is like an event? It does that function every time something does :PromptProductPurchase() ? lucas4114 607 — 3y
0
ProcessReceipt is a call back since you're returning a value to another function or in this case a CoreScript. The ProcessReceipt callback will fire every time someone purchases a product. M39a9am3R 3152 — 3y