Developer Products (Repeated Robux Pass) - Roblox Advanced Scripting #22 — Transcript
Full transcript
- 0:00oh my God I want to beat this race the
- 0:02finish line is right over there but I'm
- 0:03moving so slow right now oh my God I
- 0:06wish I have the energy to just go fast
- 0:07right now wait a minute what the would
- 0:10you like to buy run like the wind for
- 0:13100 Robux you know what that's actually
- 0:16not that bad of an idea if it means that
- 0:17I can finish this race faster all right
- 0:19let's click this wait whoa whoa whoa
- 0:21whoa whoa whoa that was that was really
- 0:24fast oh my goodness well aren't I glad I
- 0:27cheated the system okay sorry about that
- 0:30uh going back to what was happening here
- 0:32with the game what the game decided to
- 0:33do was it prompted me this purchase now
- 0:36if you remember from our last video with
- 0:37game passes this kind of does look like
- 0:39a game pass but if we do buy it and then
- 0:42uh the purchase has been successful we
- 0:43can run extremely fast but we can prompt
- 0:46the same purchase again and then we can
- 0:48consistently buy this um regardless of
- 0:50if we have ownership of this uh product
- 0:53or not and this is what's called a
- 0:55developer product where we can basically
- 0:57buy the same uh product uh repeatedly
- 1:00over and over again um that can give us
- 1:03like some sort of advantage to the game
- 1:05that doesn't require us just to buy it
- 1:07one time it allows us to buy it multiple
- 1:09times that's what I'm going to be
- 1:10teaching you how to implement in this
- 1:11video with developer products and I'm
- 1:13also going to sprinkle in using data
- 1:14stores in this video so that we can
- 1:16track our purchase history but with that
- 1:18being said let's go ahead and add Dev
- 1:20products to our game now that we
- 1:22understand it let's add developer
- 1:23products to our game uh but the first
- 1:25thing we want to do is make sure that
- 1:27our game is published so if you haven't
- 1:29published your game yet I advise doing
- 1:30that first before continuing but if you
- 1:33have already published your game what
- 1:34we're going to do is go up to game
- 1:36settings and then we're going to go to
- 1:38security down here and we want to make
- 1:40sure that we have this enabled enable
- 1:42Studio access to API Services just make
- 1:45sure this one's checked and then we
- 1:46should pretty much just be good to go
- 1:48all right so now that we have that set
- 1:49up let's create our first Dev product
- 1:51and this is going to be located within
- 1:53our monetization tab right here and then
- 1:56if we scroll down we can see that um we
- 1:59can see that that there's a developer
- 2:00product section here with a create
- 2:01button so what we're going to do is
- 2:03create this and then what's going to
- 2:05happen is it's going to automatically
- 2:07create a developer product for us down
- 2:09here in this Dev product list um there's
- 2:12no product ID yet because we need to hit
- 2:14save before roblo uh creates an asset ID
- 2:17for this product that we can use for our
- 2:20own game so we have a product name we
- 2:22have a product ID and we have a price
- 2:24for it too and if we want to modify it
- 2:26we can just click these three dots that
- 2:28are over here and then we can click edit
- 2:30so we can edit the name of this to be
- 2:32whatever we want it to be we can just
- 2:33say uh my first product or something
- 2:36like that and then we can change the
- 2:37price as well to whatever we want it to
- 2:39be maybe like 200 Robux doesn't really
- 2:41matter too much so then what we're going
- 2:43to do is hit save so then what should
- 2:45happen is if we go back to our game
- 2:46settings go to monetization then we
- 2:48should see our new product down here as
- 2:51we called it my first product with the
- 2:53product ID so what we're going to do now
- 2:56is just like in the game passes video
- 2:58we're going to take take this ID so that
- 3:01we can use it inside of our game to give
- 3:03to the player so we're going to hit copy
- 3:05ID to clipboard and then we're going to
- 3:07just close out of this so that's
- 3:09basically how we create our Game Pass
- 3:11now in order for us to prompt the
- 3:13purchase for the player so that like if
- 3:14they're playing the game we want the UI
- 3:16to drop down so that we can ask the
- 3:18player if they want to buy this we're
- 3:20going to do this on the local side um
- 3:22using a local script so we're probably
- 3:24going to insert a local script in let's
- 3:27say starter player with uh starter
- 3:29player scripts we're going to hit the
- 3:31plus sign and then we're going to insert
- 3:32a local script so just like with Game
- 3:35Pass service we need to prompt the
- 3:37purchase to the player and the way we're
- 3:38going to do that is use a service called
- 3:40Marketplace service so we're just going
- 3:43to say local Marketplace service equals
- 3:47game colon get Service Marketplace
- 3:51service and then the next thing we're
- 3:53going to do is get access to our local
- 3:55player so we're going to say local
- 3:56player equals game. players local player
- 4:01and then we're going to get the product
- 4:02ID of the developer product we just
- 4:04created so we're going to say local
- 4:06product ID equals and then we're going
- 4:08to paste in our ID that we copied from
- 4:11the game settings tab so this is our
- 4:14initial setup we have so far what we
- 4:17need to do now is prompt this purchase
- 4:19to the player and this is actually
- 4:22really easy all we need to do is just
- 4:23say uh
- 4:25Marketplace service colon prompt product
- 4:30purchase and then we're going to say
- 4:32open and close parenthesis we're going
- 4:34to pass in our player instance and then
- 4:36we're going to pass the product ID which
- 4:39we have this in a variable already so
- 4:41this is basically how you prompt a
- 4:44developer product purchase to the player
- 4:46the only thing that's different about
- 4:47this is we're saying prompt product
- 4:49purchase rather than before it was
- 4:51prompt Game Pass purchase but this time
- 4:54it's going to be a developer product so
- 4:55this is the only difference we're going
- 4:56to make here okay but we've just gotten
- 4:58through the easy part but now at this
- 5:00point things are not going to be as
- 5:02straightforward when it comes to
- 5:03handling the purchase of this product
- 5:05that we've now prompted so I want you to
- 5:08imagine how this works when we prompt
- 5:10the purchase to the player and then the
- 5:12player does decide to buy this product
- 5:14we have to essentially send that
- 5:17information to the server so that the
- 5:19server knows that this player has bought
- 5:22a developer product and we need to be
- 5:24able to process this purchase by
- 5:27creating a receipt of the product the
- 5:29player just bought and we need to figure
- 5:32out what benefits we want to give to the
- 5:34player uh for that product that they
- 5:37just bought and we also need to make
- 5:39sure that the pro and we also need to
- 5:41make sure that the purchase is
- 5:44successful and there can be a lot of
- 5:46issues that come about when we don't
- 5:48know how to properly handle purchases
- 5:51that don't become successful so that's
- 5:53something we have to take care of when
- 5:56we're processing the purchases for
- 5:57developer products I hope that part
- 5:59makes sense so with that being said what
- 6:01we're going to do now is create a script
- 6:04on the right side of the screen let's
- 6:06just make this inside of server script
- 6:07service we're going to hit the plus sign
- 6:09insert a script and here's what we're
- 6:11going to do so let's go to our local
- 6:13script uh and let's copy the marketplace
- 6:16service declaration and then paste that
- 6:18right into here uh and then we're also
- 6:20going to um make a reference to the
- 6:23players uh Service as well so we're
- 6:25going to say game colon get service
- 6:27players just like this okay so most
- 6:30likely we're going to have more than one
- 6:32developer products within the game and
- 6:34if that is the case we need to have
- 6:36functions associated with that developer
- 6:39product for when the player does buy
- 6:41that specific product like let's say the
- 6:43player buys a a 100 plus walkspeed
- 6:46developer product we need to make a
- 6:48function that pertains specifically to
- 6:51the benefit of obtaining 100 plus speed
- 6:54versus a different product um versus a
- 6:57different product we use functions for
- 6:59each individual function so essentially
- 7:02what we need to do is make a table full
- 7:04of product functions and this is what
- 7:06it's going to look like we're going to
- 7:07say local product functions equals open
- 7:11and close hard brackets so once we have
- 7:13this our key for uh each individual
- 7:16product function is basically going to
- 7:18be the product ID of each single um
- 7:22product so if we were to go back to our
- 7:24local script this is what our product ID
- 7:26is here let's just copy this uh and then
- 7:28what we're going to do is populate this
- 7:30products function by saying product
- 7:33functions open and close hard brackets
- 7:36and then we're going to paste in our
- 7:38product ID and we're going to set this
- 7:40equal to a new function open and close
- 7:42parentheses we're going to pass in the
- 7:45receipt that Roblox has created for this
- 7:48product that the player has created so
- 7:50we're just going to say receipt and then
- 7:52we're also going to pass in the player
- 7:54as well like this and then we're going
- 7:56to hit enter so essentially What's
- 7:57Happening Here is for our product
- 7:59functions table our key is going to be
- 8:02uh a specific developer product and
- 8:04we're going to set this equal to a
- 8:06function that we're going to activate if
- 8:08the player does successfully buy this
- 8:10developer product and so if we wanted to
- 8:13do this for another developer product we
- 8:14could just copy this paste it down here
- 8:16and just have this be a different
- 8:18product ID it's essentially the same
- 8:20thing it's just depends on it's just a
- 8:23matter of what we do in these bodies
- 8:26specifically so right now we're just
- 8:28going to delete this we're just going to
- 8:28go with one for right now okay so let's
- 8:31say we want this product to give 100
- 8:34plus speed to the player every time they
- 8:37buy it or we could just make it 50 it
- 8:38doesn't have to be 100 so we can just
- 8:39say 50 plus speed for this developer
- 8:42product what we need to do first is
- 8:44access the humanoid but we need to do um
- 8:47the character first so we're going to
- 8:48say local charact character equals
- 8:53player do character and then we're going
- 8:55to access the humanoid by saying local
- 8:57humanoid equals character find First
- 9:00Child open and close
- 9:02parenthesis humanoid and then we're
- 9:04going to check if that humanoid does
- 9:06exist we're going to say if humanoid
- 9:08then we're just going to say humanoid do
- 9:10walkspeed
- 9:11plus equals 50 so this is essentially
- 9:14saying take the current humanoid walk
- 9:16speed and add 50 to that so by default
- 9:19the walk speed is 16 so if we add 50
- 9:21then we will definitely see a very
- 9:23noticeable difference so we've granted
- 9:25the benefits but what we need to do is
- 9:26return true so that we know that this um
- 9:29purchase has been successful I'm going
- 9:31to show you why this is important just a
- 9:32little bit so we're just going to return
- 9:33true that's basically all we're going to
- 9:35be doing uh for this and this is how we
- 9:38create uh a function that can execute
- 9:41the benefits that we're going to give to
- 9:43the player okay so the next thing we
- 9:44need to do is figure out how we can
- 9:46process the receipts that Roblox is
- 9:48creating for the developer products that
- 9:50the players are buying we need to do
- 9:52this by creating a function that
- 9:54basically processes the receipts for us
- 9:56and then set that function to a call
- 9:58back
- 9:59uh for the process receipt um property
- 10:02in Marketplace service I'm going to show
- 10:03you what that looks like right now so
- 10:05here's the first thing we're going to do
- 10:06we're going to like I said create the
- 10:08call back function for processing our
- 10:10receipts we're just going to say local
- 10:13function process receipt open and close
- 10:17parenthesis and then what's going to be
- 10:19passed into here is a
- 10:22receipt info table so then we're going
- 10:25to hit enter like this and so this is
- 10:28the basic structure of our process
- 10:30receipt but now what we need to do is
- 10:32set Marketplace Services process receipt
- 10:35call back to this function that we just
- 10:37created so down here we're going to
- 10:40say Marketplace
- 10:43service. process receipt equals process
- 10:49receipt so basically our function that
- 10:51we just created up here so when we say
- 10:54process receipt and then every time a
- 10:55player buys something it's going to pass
- 10:57in a a receipt in info table that
- 11:00basically tells us information about the
- 11:03about the about the product the player
- 11:05just bought and there are two pieces of
- 11:07information that we do want from this
- 11:09the first one is the user ID and then
- 11:11the second one is the product ID of the
- 11:14of the thing the player just bought so
- 11:15what we're going to do is say local user
- 11:18ID equals receip
- 11:21info. player ID and then the next one is
- 11:24going to be the product ID so we're
- 11:25going to say local product ID equals
- 11:28receipt
- 11:29info. product ID okay so next thing
- 11:32we're going to do is get the player
- 11:33using the user ID that we just got so
- 11:35we're going to say local player equals
- 11:38players colon get player by user ID and
- 11:44then we're going to pass in the user ID
- 11:46like this and then we're going to check
- 11:47if this player does exist so if player
- 11:50then what we're now going to do is try
- 11:52and get this product function for this
- 11:55developer product that we have here for
- 11:5750 plus speed since now we have the
- 11:59product ID uh within our control uh to
- 12:02be able to know which products the
- 12:03purchase which products the player
- 12:05bought so this is so we're basically
- 12:07going to wrap this in a variable by
- 12:08saying local Handler equals product
- 12:13functions and then in these hard
- 12:16brackets what we're going to do is put
- 12:18in the product ID like let's say this
- 12:20product ID was this one right here we're
- 12:23going to put that inside of here and
- 12:25that's how we're essentially going to
- 12:26find this function uh for the hand
- 12:29right here so Handler is now set equal
- 12:31to this function now that we have our
- 12:33function let's wrap this in a PE call
- 12:35we're going to say local success comma
- 12:39result equals P call and and we're going
- 12:41to be writing this P call like so we're
- 12:44going to first pass in our Handler
- 12:47function so we're going to pass in the
- 12:48Handler and then whatever is going to be
- 12:50after this is going to be the arguments
- 12:53that are inside of this function so the
- 12:54first one is going to be the receipt
- 12:58info and then the second one is going to
- 13:00be the player so we're just simply going
- 13:02to pass in the player and that is how uh
- 13:05we're going to structure our PE call
- 13:07like so and we're going to check if this
- 13:09was successful we're going to say if
- 13:10success then uh we're going to tell
- 13:14Roblox that this purchase has indeed
- 13:16been successful and the way we tell
- 13:18Roblox that this has been successful is
- 13:20we return an enum value that basically
- 13:23says that this is a product decision of
- 13:27it being granted so this is is what it's
- 13:29going to look like we're going to say
- 13:30return enum do product purchas decision
- 13:36Dot and as you can see there's two
- 13:38results here so there's not processed
- 13:39yet and then purchase granted this one
- 13:41is going to be purchase granted because
- 13:43this has been Su success because this
- 13:45has been successful not processed yet
- 13:47basically means that um the purchase is
- 13:50still happening but there seems to be
- 13:52some issues going on with it so we need
- 13:53to make sure that we are handling um
- 13:56this situation properly so we're going
- 13:58to hit purch just granted and that's
- 13:59basically what it's going to do here so
- 14:01if this was not successful though so
- 14:03we're just going to say else like this
- 14:04we're going to uh let's say we're going
- 14:06to make an error message here that we're
- 14:08just going to say uh failed to make the
- 14:14product product purchase uh and then
- 14:18we're and then we can just pass in the
- 14:20receipt info so that we know uh exactly
- 14:22what kind of uh so that we know exactly
- 14:25what game pass failed from this decision
- 14:28okay and then finally we have to make
- 14:30sure to handle what happens if the
- 14:32purchase has not been granted we're
- 14:34basically just going to go down here and
- 14:36say return en. product purchas decision
- 14:42dot notprocessed yet so if none of this
- 14:46works in here like if the player does
- 14:48not exist uh if the Handler does not
- 14:50work then it's just going to go down
- 14:52here and return not processed yet so
- 14:55that Roblox can handle whatever is going
- 14:57to happen here so that the the player
- 14:59does not get charged If the product does
- 15:02fail so this is our basic structure for
- 15:05uh handling our developer product I hope
- 15:08this made sense to you so far but let's
- 15:10go back to our local script and I'm
- 15:12actually going to add a task. weight for
- 15:14like about 2 seconds so that uh the game
- 15:17gives me enough time to load into the
- 15:18game so now we're going to go into the
- 15:20game and see the result of this prompt
- 15:23that's being um shown right here okay so
- 15:25it says right here would you like to buy
- 15:27my first product I'm going to
- 15:29uh click this and then what's going to
- 15:30happen is the purchase has been success
- 15:33the purchase has been successful now if
- 15:35I run you can see that I'm actually
- 15:37moving faster now because I bought the
- 15:40game pad because I bought the developer
- 15:42product um compared to my walk speed
- 15:45being 16 the walk speed now should be uh
- 15:50the walk speed should now be 66 as you
- 15:52can see right here because I
- 15:53successfully bought the developer
- 15:55products so it's pretty much working as
- 15:56expected and that's how you handle uh
- 15:58developer product purchases in your
- 16:00Roblox game okay now let's say we wanted
- 16:02to get product information for a
- 16:05specific developer product so that we
- 16:06can use it to either um know what
- 16:10information this product does have uh or
- 16:12we could just display it in our game if
- 16:14we have the information to the product
- 16:16itself what we can do is go to our local
- 16:18script and we can basically just use a
- 16:21function that Marketplace service has
- 16:23called get product info uh pass in our
- 16:25product ID so that we can uh get back a
- 16:28table full of information about it so
- 16:30here's what we're going to do we're
- 16:31going to wrap this in a call by saying
- 16:33local success comma product info equals
- 16:38P call
- 16:40function function open close parentheses
- 16:43enter and then we're simply just going
- 16:45to return Marketplace service colon get
- 16:49product info open and close parentheses
- 16:52so we're first going to pass in our
- 16:54product ID over here and then we need an
- 16:57info type and this takes in an and and
- 17:00this takes in an enum info type so we're
- 17:02basically just going to say en. infotype
- 17:06and as you can see there's a lot of
- 17:07things we can select from uh what we are
- 17:09interested in is product because that is
- 17:12the product type that we are looking for
- 17:14in this case so now that we have our
- 17:16product type let's basically just go so
- 17:19now that we have our product type if we
- 17:21want to know what's inside of this table
- 17:23uh we can just Loop through all of the
- 17:25keys and values that are inside of this
- 17:27table so we're just going to say for key
- 17:30comma value in pairs open and close
- 17:33parentheses product info do oh sorry I
- 17:37forgot to put the do there uh we're just
- 17:38simply going to print key comma value
- 17:42just like this so now that we have this
- 17:44let's go into the game and hit play so
- 17:47what should happen is after about 2
- 17:48seconds it should print out all of the
- 17:50information of the developer products
- 17:53that we created in this game so we have
- 17:55something like the asset type the target
- 17:56ID um the minimum membership when it was
- 18:00created is limited is for sale there
- 18:02there's a whole bunch of stuff we can
- 18:04look at here uh for this product
- 18:06information so that is how you can
- 18:08access product information about a
- 18:10specific developer product if you need
- 18:12to use this in your game so for this
- 18:13last part of the video it's actually a
- 18:15pretty important one and that is keeping
- 18:17track of our purchase history for each
- 18:19player playing the game and the reason
- 18:21this is very important is because this
- 18:23is the only way we know if a player has
- 18:27actually bought a product or not because
- 18:28Roblox isn't going to do it themselves
- 18:30automatically it's up to us as the
- 18:32developers to be able to keep track of
- 18:34the purchase history that the player
- 18:36does have and it's not as intuitive as
- 18:38game passes so it's going to be a little
- 18:41tricky to um keep track of player
- 18:43history so I'm going to try and walk
- 18:45through so that you can understand how
- 18:47this stuff works so here's what we're
- 18:49going to do we're going to go to our
- 18:50script and at the very top we're going
- 18:52to get access to the data store uh
- 18:55service we're going to say local data
- 18:58store service equals game get service
- 19:02data store service and then we're going
- 19:05to access um our p and we're going to
- 19:09make a purchase history data store so
- 19:11we're just going to say local purchase
- 19:14history equals data store service colon
- 19:18get data store open and close
- 19:21parenthesis and we're going to call this
- 19:24purchase history so now we're going to
- 19:26come down here and make a few
- 19:28modifications to our process receipt uh
- 19:31call back the first thing we're going to
- 19:32do is figure out how we're going to
- 19:34structure our data store to know if the
- 19:36player has bought this uh product with
- 19:39like this specific transaction that
- 19:41they've done uh with receipt info uh
- 19:44there's a property here that's called
- 19:46receip
- 19:47info. purchase ID so this is essentially
- 19:50a value that is very unique to this
- 19:54specific purchase that this player is
- 19:55making so it would be a product that
- 19:58this player bought at this specific time
- 20:01and like anything else that ties into
- 20:03this specific uh purchase ID that has
- 20:05been um generated for us with this
- 20:08receipt so this is what we're going to
- 20:10use to determine a this so this is what
- 20:13we're going going to use to determine
- 20:15this specific transaction that this
- 20:17player has made so we're going to delete
- 20:19this so what we need to do is create a a
- 20:22player product ID for this specific
- 20:25transaction that this player is making
- 20:27so what we're going to do drop two lines
- 20:28and say local player product key and
- 20:33sorry I meant to say key not ID like
- 20:35this is going to be the key used for our
- 20:37data store so we're going to set this
- 20:40equal to a key that looks something like
- 20:43this we're going to say user ID dot dot
- 20:46for concatenation and then we're going
- 20:48to put in an underscore and then dot dot
- 20:50we're going to concatenate this again
- 20:53with the receip info. purchase ID so the
- 20:57way this is going to be structured is
- 20:58we're going to have our player's user ID
- 21:00and then this is going to be separated
- 21:01with uh the purchase ID the unique ID of
- 21:05the receipt that of the product that
- 21:07we're buying and so now down here we're
- 21:09going to uh make a PE call so that we
- 21:11can use get async with the data store so
- 21:13that we know that we're trying to
- 21:15retrieve this exact information from
- 21:17here so we're going to say local success
- 21:20error message equals P call function
- 21:24open and close parentheses enter and
- 21:27then what we we're going to do is in
- 21:29order to determine whether this actually
- 21:30was successful or not we're just going
- 21:32to make another variable up here by
- 21:34saying local purchased equals false and
- 21:38then we're going to set purchased down
- 21:41here equal to the get async function
- 21:44we're going to say purchase history
- 21:47colon get a sync open and close
- 21:50parenthesis and as the key it's going to
- 21:52be our player product ID like this and
- 21:57so once we do do this we're going to
- 21:58check if this was successful so we're
- 22:00going to say if success then but not
- 22:02just success we're also going to say if
- 22:05the purchase was successful as well then
- 22:07what we're going to do is simply just
- 22:09return the purchase granted down here
- 22:12regardless because if we know that this
- 22:14is already in the data store then we
- 22:16already know that this is a successful
- 22:18purchase so we don't have to do anything
- 22:20else after that so we're just going to
- 22:22pass it in just like that and uh this
- 22:24should be said uh player product key
- 22:26instead of ID my mistake
- 22:28and then what we're going to do is say
- 22:30else if not success so if this was not
- 22:34successful then what we're going to do
- 22:35is simply just print out an error
- 22:36message by saying um purchase has not
- 22:41been
- 22:43successful just like that I hope this
- 22:45part makes sense to you when we are
- 22:48determining the key for this purchase
- 22:50history it's basically going to be the
- 22:52players's user ID with the purchase ID
- 22:54of this specific transaction and we're
- 22:56going to check inside of this purchase
- 22:58history data store if this does exist
- 23:00and if this and if it does exist then
- 23:03we're basically going to return the
- 23:04value that's passed back from the
- 23:06purchase history using this product key
- 23:09and purchase is determined by either
- 23:10true or false so false is if it doesn't
- 23:13exist already and true if it already
- 23:15does exist in the data store so that's
- 23:17why we check if it's successful and if
- 23:18it's also been purchased already then
- 23:20we're just going to say that purchase
- 23:21has been granted we don't need to we
- 23:23don't need to do anything else after
- 23:24that but if it was not successful then
- 23:26we're just going to say that purchase
- 23:28has not been successful so that's only
- 23:29one part of it but that is an important
- 23:32part that we need to add into our script
- 23:34and I hope this part has made sense to
- 23:37you at least so far well since we do
- 23:38have an error message we actually could
- 23:40just concatenate this um with the error
- 23:43message down here so we can just say
- 23:45error message like this because we we
- 23:47basically just have it right here uh so
- 23:50this is basically the so this is
- 23:52basically one way we can tell more
- 23:54information about this error message if
- 23:56it does ever come down here okay so we
- 23:58have the script down here that basically
- 24:00gives the benefits to the player if they
- 24:02buy a specific product but what we need
- 24:04to do now is wrap this in a PE call uh
- 24:07by first checking if this purchase is
- 24:11already in the data store if this
- 24:13purchase was already granted to the
- 24:15player so that the script doesn't
- 24:16randomly just duplicate the benefits for
- 24:19the player if they accidentally do buy
- 24:20it twice and we're going to do a second
- 24:23check to make sure that this product has
- 24:25already been granted to the player uh
- 24:28and we're going to utilize this using
- 24:30update async if you remember that with
- 24:32data Stores um this is how it's going to
- 24:35look we're going to drop a line down
- 24:36here before we declare player we're
- 24:38going to say local success comma is
- 24:42purchase recorded equals P call function
- 24:46open and close parentheses enter and
- 24:48then for this Boolean right here is
- 24:51purchase recorded we're going to set
- 24:53this equal to a return value given by
- 24:56this data stores up update async
- 24:58function so this is basically what it's
- 25:01going to look like uh you can just copy
- 25:02what I do and I'll explain what's going
- 25:03to happen here we're going to say return
- 25:06purchase history colon update async open
- 25:11and close parentheses we're going to
- 25:12pass in the key of the player product
- 25:17key and then we're going to um and then
- 25:20the second argument is going to be a
- 25:22function with a past parameter in here
- 25:25called already purchased
- 25:28and then we're going to hit enter like
- 25:29this we're going to check if already
- 25:32purchased is true then we're just simply
- 25:35going to return true and then there's
- 25:38going to be more things we're going to
- 25:40do down here in just a little bit but
- 25:41first I want to explain what's happening
- 25:43here with this code snippet so we're
- 25:45basically creating another PE call with
- 25:47is purchase recorded this is going to be
- 25:49a Boolean that we're going to return and
- 25:51we're going to set this equal to a p
- 25:53call function of this return value
- 25:56that's going to be set to is purchase
- 25:58recorded uh from this update async
- 26:02function um so essentially What's
- 26:04Happening Here is with this player
- 26:06product key this key in particular with
- 26:09this purchase history if this gets
- 26:11updated like let's say the value for um
- 26:15let's say the value for this product key
- 26:17inside a purchase history gets updated
- 26:19like the value gets updated is we're
- 26:21going to create a new function with a
- 26:24past argument already purchased uh to
- 26:27then have some sort of return value
- 26:29inside of this update async function to
- 26:32then be placed back into is p is
- 26:35purchase recorded because as you know if
- 26:37we take the player product key put it
- 26:39inside a purchase history get the value
- 26:42from that key in the purchase history
- 26:45that value is going to be placed into
- 26:48the function parameter here inside of um
- 26:51inside of the inside of the parameter
- 26:54for this function that we just created
- 26:55already purchased already purchased is
- 26:58the value of whatever we got from the
- 27:01purchase history using this player
- 27:02product key I hope that part made sense
- 27:05to you and it's important that you do
- 27:06understand that part so if we see if the
- 27:09purchase has already been successful
- 27:10then we're simply just going to return
- 27:11true and if not then we're going to
- 27:13continue doing more checks down here so
- 27:15literally what we're going to do is take
- 27:17this code snippet with uh the granting
- 27:19the benefits for the player we're going
- 27:21to we're going to cut this paste it down
- 27:23here and then we're also going to return
- 27:26true down here as well like at the very
- 27:29endend of this update async function for
- 27:32the is Rec is purchase recorded Boolean
- 27:35but since we've structured this a little
- 27:36differently since we're going to return
- 27:38true no matter what instead what we're
- 27:40going to do is return a Boolean of false
- 27:44if uh any of these checks go wrong so
- 27:47instead of this if else statement right
- 27:50here what we're going to do instead is
- 27:51say if not success or not result
- 27:58then we're going to throw in an error
- 28:01saying purchase has been
- 28:05unsuccessful and then we can write down
- 28:07the product that failed so we're just
- 28:09going to say receip info. product ID and
- 28:14now there's one final step and that is
- 28:16determining the product decision because
- 28:19we're not just going to rely on this
- 28:21just being not processed yet all the
- 28:24time uh so we're just going to delete
- 28:26this and what we're going to do instead
- 28:28is make an if else if else structure
- 28:31here so the first thing we're going to
- 28:32do is check if it was not
- 28:34successful like if um like if this
- 28:38variable if this success variable here
- 28:40was just not successful then what we're
- 28:42going to do is give an error by saying
- 28:45uh purchase data store has been
- 28:50unsuccessful something like that uh and
- 28:52then we're going to return an en.
- 28:55product purchase decision do
- 28:58notprocessed yet and then we can make
- 29:01another else if is purchased recorded
- 29:05equals nil so what this means is if the
- 29:08purchase that we did like if there was
- 29:10no value that was updated in the data
- 29:12store was changed then we're basically
- 29:14going to also return not processed yet
- 29:17because there is an issue going on with
- 29:18that and then if both of these are not
- 29:21the case then that means the purchase
- 29:23has been successful so we're going to
- 29:24say uh
- 29:26return uh we're basically just going to
- 29:28take this and then we're going to return
- 29:30purchase granted okay that was kind of a
- 29:34lot to take in but we have finished our
- 29:37product we have finished our data store
- 29:40script for handling uh all of these
- 29:43different scenarios that we might have
- 29:45when it comes to handling our developer
- 29:47product purchases it's very it is kind
- 29:49of sophisticated at first but if you do
- 29:51understand what's happening here with
- 29:52the script then you'll have a much
- 29:55better time implementing this in the
- 29:56future especially when you incorporate
- 29:58more game passes uh and you decide to
- 30:01work more analytically with uh all of
- 30:04these purchases that are happening in
- 30:05your game so that is basically
- 30:07everything that has to do with developer
- 30:09products and I hope you found this video
- 30:10to be very informative like I said I
- 30:11hope you found this video to be very
- 30:13informative it was a bit longer than I
- 30:14thought but that's because I want you to
- 30:16get a full grasp of how data I want you
- 30:19to get a full grasp of how these things
- 30:21work because I know data stores is one
- 30:23of the most uh confusing topics to new
- 30:25developers and so I wanted to to take
- 30:27the time to go through step by step on
- 30:30my understanding of using data stores uh
- 30:33with developer products and things like
- 30:34that so if you want to refresh your
- 30:37memory on the basics of data stores then
- 30:39I will link to my data stores video that
- 30:41I'll have for you right here in this
- 30:43video but with that being said I hope
- 30:45you found this video to be helpful and I
- 30:47will see you in the next episode take
- 30:50care
About this transcript
This page contains the full transcript of Developer Products (Repeated Robux Pass) - Roblox Advanced Scripting #22 by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 5,933 words across 805 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.