YouTube2Text

Developer Products (Repeated Robux Pass) - Roblox Advanced Scripting #22 — Transcript

by BrawlDev · 5,933 words · 805 segments · language en · Watch on YouTube

Full transcript

  1. 0:00oh my God I want to beat this race the
  2. 0:02finish line is right over there but I'm
  3. 0:03moving so slow right now oh my God I
  4. 0:06wish I have the energy to just go fast
  5. 0:07right now wait a minute what the would
  6. 0:10you like to buy run like the wind for
  7. 0:13100 Robux you know what that's actually
  8. 0:16not that bad of an idea if it means that
  9. 0:17I can finish this race faster all right
  10. 0:19let's click this wait whoa whoa whoa
  11. 0:21whoa whoa whoa that was that was really
  12. 0:24fast oh my goodness well aren't I glad I
  13. 0:27cheated the system okay sorry about that
  14. 0:30uh going back to what was happening here
  15. 0:32with the game what the game decided to
  16. 0:33do was it prompted me this purchase now
  17. 0:36if you remember from our last video with
  18. 0:37game passes this kind of does look like
  19. 0:39a game pass but if we do buy it and then
  20. 0:42uh the purchase has been successful we
  21. 0:43can run extremely fast but we can prompt
  22. 0:46the same purchase again and then we can
  23. 0:48consistently buy this um regardless of
  24. 0:50if we have ownership of this uh product
  25. 0:53or not and this is what's called a
  26. 0:55developer product where we can basically
  27. 0:57buy the same uh product uh repeatedly
  28. 1:00over and over again um that can give us
  29. 1:03like some sort of advantage to the game
  30. 1:05that doesn't require us just to buy it
  31. 1:07one time it allows us to buy it multiple
  32. 1:09times that's what I'm going to be
  33. 1:10teaching you how to implement in this
  34. 1:11video with developer products and I'm
  35. 1:13also going to sprinkle in using data
  36. 1:14stores in this video so that we can
  37. 1:16track our purchase history but with that
  38. 1:18being said let's go ahead and add Dev
  39. 1:20products to our game now that we
  40. 1:22understand it let's add developer
  41. 1:23products to our game uh but the first
  42. 1:25thing we want to do is make sure that
  43. 1:27our game is published so if you haven't
  44. 1:29published your game yet I advise doing
  45. 1:30that first before continuing but if you
  46. 1:33have already published your game what
  47. 1:34we're going to do is go up to game
  48. 1:36settings and then we're going to go to
  49. 1:38security down here and we want to make
  50. 1:40sure that we have this enabled enable
  51. 1:42Studio access to API Services just make
  52. 1:45sure this one's checked and then we
  53. 1:46should pretty much just be good to go
  54. 1:48all right so now that we have that set
  55. 1:49up let's create our first Dev product
  56. 1:51and this is going to be located within
  57. 1:53our monetization tab right here and then
  58. 1:56if we scroll down we can see that um we
  59. 1:59can see that that there's a developer
  60. 2:00product section here with a create
  61. 2:01button so what we're going to do is
  62. 2:03create this and then what's going to
  63. 2:05happen is it's going to automatically
  64. 2:07create a developer product for us down
  65. 2:09here in this Dev product list um there's
  66. 2:12no product ID yet because we need to hit
  67. 2:14save before roblo uh creates an asset ID
  68. 2:17for this product that we can use for our
  69. 2:20own game so we have a product name we
  70. 2:22have a product ID and we have a price
  71. 2:24for it too and if we want to modify it
  72. 2:26we can just click these three dots that
  73. 2:28are over here and then we can click edit
  74. 2:30so we can edit the name of this to be
  75. 2:32whatever we want it to be we can just
  76. 2:33say uh my first product or something
  77. 2:36like that and then we can change the
  78. 2:37price as well to whatever we want it to
  79. 2:39be maybe like 200 Robux doesn't really
  80. 2:41matter too much so then what we're going
  81. 2:43to do is hit save so then what should
  82. 2:45happen is if we go back to our game
  83. 2:46settings go to monetization then we
  84. 2:48should see our new product down here as
  85. 2:51we called it my first product with the
  86. 2:53product ID so what we're going to do now
  87. 2:56is just like in the game passes video
  88. 2:58we're going to take take this ID so that
  89. 3:01we can use it inside of our game to give
  90. 3:03to the player so we're going to hit copy
  91. 3:05ID to clipboard and then we're going to
  92. 3:07just close out of this so that's
  93. 3:09basically how we create our Game Pass
  94. 3:11now in order for us to prompt the
  95. 3:13purchase for the player so that like if
  96. 3:14they're playing the game we want the UI
  97. 3:16to drop down so that we can ask the
  98. 3:18player if they want to buy this we're
  99. 3:20going to do this on the local side um
  100. 3:22using a local script so we're probably
  101. 3:24going to insert a local script in let's
  102. 3:27say starter player with uh starter
  103. 3:29player scripts we're going to hit the
  104. 3:31plus sign and then we're going to insert
  105. 3:32a local script so just like with Game
  106. 3:35Pass service we need to prompt the
  107. 3:37purchase to the player and the way we're
  108. 3:38going to do that is use a service called
  109. 3:40Marketplace service so we're just going
  110. 3:43to say local Marketplace service equals
  111. 3:47game colon get Service Marketplace
  112. 3:51service and then the next thing we're
  113. 3:53going to do is get access to our local
  114. 3:55player so we're going to say local
  115. 3:56player equals game. players local player
  116. 4:01and then we're going to get the product
  117. 4:02ID of the developer product we just
  118. 4:04created so we're going to say local
  119. 4:06product ID equals and then we're going
  120. 4:08to paste in our ID that we copied from
  121. 4:11the game settings tab so this is our
  122. 4:14initial setup we have so far what we
  123. 4:17need to do now is prompt this purchase
  124. 4:19to the player and this is actually
  125. 4:22really easy all we need to do is just
  126. 4:23say uh
  127. 4:25Marketplace service colon prompt product
  128. 4:30purchase and then we're going to say
  129. 4:32open and close parenthesis we're going
  130. 4:34to pass in our player instance and then
  131. 4:36we're going to pass the product ID which
  132. 4:39we have this in a variable already so
  133. 4:41this is basically how you prompt a
  134. 4:44developer product purchase to the player
  135. 4:46the only thing that's different about
  136. 4:47this is we're saying prompt product
  137. 4:49purchase rather than before it was
  138. 4:51prompt Game Pass purchase but this time
  139. 4:54it's going to be a developer product so
  140. 4:55this is the only difference we're going
  141. 4:56to make here okay but we've just gotten
  142. 4:58through the easy part but now at this
  143. 5:00point things are not going to be as
  144. 5:02straightforward when it comes to
  145. 5:03handling the purchase of this product
  146. 5:05that we've now prompted so I want you to
  147. 5:08imagine how this works when we prompt
  148. 5:10the purchase to the player and then the
  149. 5:12player does decide to buy this product
  150. 5:14we have to essentially send that
  151. 5:17information to the server so that the
  152. 5:19server knows that this player has bought
  153. 5:22a developer product and we need to be
  154. 5:24able to process this purchase by
  155. 5:27creating a receipt of the product the
  156. 5:29player just bought and we need to figure
  157. 5:32out what benefits we want to give to the
  158. 5:34player uh for that product that they
  159. 5:37just bought and we also need to make
  160. 5:39sure that the pro and we also need to
  161. 5:41make sure that the purchase is
  162. 5:44successful and there can be a lot of
  163. 5:46issues that come about when we don't
  164. 5:48know how to properly handle purchases
  165. 5:51that don't become successful so that's
  166. 5:53something we have to take care of when
  167. 5:56we're processing the purchases for
  168. 5:57developer products I hope that part
  169. 5:59makes sense so with that being said what
  170. 6:01we're going to do now is create a script
  171. 6:04on the right side of the screen let's
  172. 6:06just make this inside of server script
  173. 6:07service we're going to hit the plus sign
  174. 6:09insert a script and here's what we're
  175. 6:11going to do so let's go to our local
  176. 6:13script uh and let's copy the marketplace
  177. 6:16service declaration and then paste that
  178. 6:18right into here uh and then we're also
  179. 6:20going to um make a reference to the
  180. 6:23players uh Service as well so we're
  181. 6:25going to say game colon get service
  182. 6:27players just like this okay so most
  183. 6:30likely we're going to have more than one
  184. 6:32developer products within the game and
  185. 6:34if that is the case we need to have
  186. 6:36functions associated with that developer
  187. 6:39product for when the player does buy
  188. 6:41that specific product like let's say the
  189. 6:43player buys a a 100 plus walkspeed
  190. 6:46developer product we need to make a
  191. 6:48function that pertains specifically to
  192. 6:51the benefit of obtaining 100 plus speed
  193. 6:54versus a different product um versus a
  194. 6:57different product we use functions for
  195. 6:59each individual function so essentially
  196. 7:02what we need to do is make a table full
  197. 7:04of product functions and this is what
  198. 7:06it's going to look like we're going to
  199. 7:07say local product functions equals open
  200. 7:11and close hard brackets so once we have
  201. 7:13this our key for uh each individual
  202. 7:16product function is basically going to
  203. 7:18be the product ID of each single um
  204. 7:22product so if we were to go back to our
  205. 7:24local script this is what our product ID
  206. 7:26is here let's just copy this uh and then
  207. 7:28what we're going to do is populate this
  208. 7:30products function by saying product
  209. 7:33functions open and close hard brackets
  210. 7:36and then we're going to paste in our
  211. 7:38product ID and we're going to set this
  212. 7:40equal to a new function open and close
  213. 7:42parentheses we're going to pass in the
  214. 7:45receipt that Roblox has created for this
  215. 7:48product that the player has created so
  216. 7:50we're just going to say receipt and then
  217. 7:52we're also going to pass in the player
  218. 7:54as well like this and then we're going
  219. 7:56to hit enter so essentially What's
  220. 7:57Happening Here is for our product
  221. 7:59functions table our key is going to be
  222. 8:02uh a specific developer product and
  223. 8:04we're going to set this equal to a
  224. 8:06function that we're going to activate if
  225. 8:08the player does successfully buy this
  226. 8:10developer product and so if we wanted to
  227. 8:13do this for another developer product we
  228. 8:14could just copy this paste it down here
  229. 8:16and just have this be a different
  230. 8:18product ID it's essentially the same
  231. 8:20thing it's just depends on it's just a
  232. 8:23matter of what we do in these bodies
  233. 8:26specifically so right now we're just
  234. 8:28going to delete this we're just going to
  235. 8:28go with one for right now okay so let's
  236. 8:31say we want this product to give 100
  237. 8:34plus speed to the player every time they
  238. 8:37buy it or we could just make it 50 it
  239. 8:38doesn't have to be 100 so we can just
  240. 8:39say 50 plus speed for this developer
  241. 8:42product what we need to do first is
  242. 8:44access the humanoid but we need to do um
  243. 8:47the character first so we're going to
  244. 8:48say local charact character equals
  245. 8:53player do character and then we're going
  246. 8:55to access the humanoid by saying local
  247. 8:57humanoid equals character find First
  248. 9:00Child open and close
  249. 9:02parenthesis humanoid and then we're
  250. 9:04going to check if that humanoid does
  251. 9:06exist we're going to say if humanoid
  252. 9:08then we're just going to say humanoid do
  253. 9:10walkspeed
  254. 9:11plus equals 50 so this is essentially
  255. 9:14saying take the current humanoid walk
  256. 9:16speed and add 50 to that so by default
  257. 9:19the walk speed is 16 so if we add 50
  258. 9:21then we will definitely see a very
  259. 9:23noticeable difference so we've granted
  260. 9:25the benefits but what we need to do is
  261. 9:26return true so that we know that this um
  262. 9:29purchase has been successful I'm going
  263. 9:31to show you why this is important just a
  264. 9:32little bit so we're just going to return
  265. 9:33true that's basically all we're going to
  266. 9:35be doing uh for this and this is how we
  267. 9:38create uh a function that can execute
  268. 9:41the benefits that we're going to give to
  269. 9:43the player okay so the next thing we
  270. 9:44need to do is figure out how we can
  271. 9:46process the receipts that Roblox is
  272. 9:48creating for the developer products that
  273. 9:50the players are buying we need to do
  274. 9:52this by creating a function that
  275. 9:54basically processes the receipts for us
  276. 9:56and then set that function to a call
  277. 9:58back
  278. 9:59uh for the process receipt um property
  279. 10:02in Marketplace service I'm going to show
  280. 10:03you what that looks like right now so
  281. 10:05here's the first thing we're going to do
  282. 10:06we're going to like I said create the
  283. 10:08call back function for processing our
  284. 10:10receipts we're just going to say local
  285. 10:13function process receipt open and close
  286. 10:17parenthesis and then what's going to be
  287. 10:19passed into here is a
  288. 10:22receipt info table so then we're going
  289. 10:25to hit enter like this and so this is
  290. 10:28the basic structure of our process
  291. 10:30receipt but now what we need to do is
  292. 10:32set Marketplace Services process receipt
  293. 10:35call back to this function that we just
  294. 10:37created so down here we're going to
  295. 10:40say Marketplace
  296. 10:43service. process receipt equals process
  297. 10:49receipt so basically our function that
  298. 10:51we just created up here so when we say
  299. 10:54process receipt and then every time a
  300. 10:55player buys something it's going to pass
  301. 10:57in a a receipt in info table that
  302. 11:00basically tells us information about the
  303. 11:03about the about the product the player
  304. 11:05just bought and there are two pieces of
  305. 11:07information that we do want from this
  306. 11:09the first one is the user ID and then
  307. 11:11the second one is the product ID of the
  308. 11:14of the thing the player just bought so
  309. 11:15what we're going to do is say local user
  310. 11:18ID equals receip
  311. 11:21info. player ID and then the next one is
  312. 11:24going to be the product ID so we're
  313. 11:25going to say local product ID equals
  314. 11:28receipt
  315. 11:29info. product ID okay so next thing
  316. 11:32we're going to do is get the player
  317. 11:33using the user ID that we just got so
  318. 11:35we're going to say local player equals
  319. 11:38players colon get player by user ID and
  320. 11:44then we're going to pass in the user ID
  321. 11:46like this and then we're going to check
  322. 11:47if this player does exist so if player
  323. 11:50then what we're now going to do is try
  324. 11:52and get this product function for this
  325. 11:55developer product that we have here for
  326. 11:5750 plus speed since now we have the
  327. 11:59product ID uh within our control uh to
  328. 12:02be able to know which products the
  329. 12:03purchase which products the player
  330. 12:05bought so this is so we're basically
  331. 12:07going to wrap this in a variable by
  332. 12:08saying local Handler equals product
  333. 12:13functions and then in these hard
  334. 12:16brackets what we're going to do is put
  335. 12:18in the product ID like let's say this
  336. 12:20product ID was this one right here we're
  337. 12:23going to put that inside of here and
  338. 12:25that's how we're essentially going to
  339. 12:26find this function uh for the hand
  340. 12:29right here so Handler is now set equal
  341. 12:31to this function now that we have our
  342. 12:33function let's wrap this in a PE call
  343. 12:35we're going to say local success comma
  344. 12:39result equals P call and and we're going
  345. 12:41to be writing this P call like so we're
  346. 12:44going to first pass in our Handler
  347. 12:47function so we're going to pass in the
  348. 12:48Handler and then whatever is going to be
  349. 12:50after this is going to be the arguments
  350. 12:53that are inside of this function so the
  351. 12:54first one is going to be the receipt
  352. 12:58info and then the second one is going to
  353. 13:00be the player so we're just simply going
  354. 13:02to pass in the player and that is how uh
  355. 13:05we're going to structure our PE call
  356. 13:07like so and we're going to check if this
  357. 13:09was successful we're going to say if
  358. 13:10success then uh we're going to tell
  359. 13:14Roblox that this purchase has indeed
  360. 13:16been successful and the way we tell
  361. 13:18Roblox that this has been successful is
  362. 13:20we return an enum value that basically
  363. 13:23says that this is a product decision of
  364. 13:27it being granted so this is is what it's
  365. 13:29going to look like we're going to say
  366. 13:30return enum do product purchas decision
  367. 13:36Dot and as you can see there's two
  368. 13:38results here so there's not processed
  369. 13:39yet and then purchase granted this one
  370. 13:41is going to be purchase granted because
  371. 13:43this has been Su success because this
  372. 13:45has been successful not processed yet
  373. 13:47basically means that um the purchase is
  374. 13:50still happening but there seems to be
  375. 13:52some issues going on with it so we need
  376. 13:53to make sure that we are handling um
  377. 13:56this situation properly so we're going
  378. 13:58to hit purch just granted and that's
  379. 13:59basically what it's going to do here so
  380. 14:01if this was not successful though so
  381. 14:03we're just going to say else like this
  382. 14:04we're going to uh let's say we're going
  383. 14:06to make an error message here that we're
  384. 14:08just going to say uh failed to make the
  385. 14:14product product purchase uh and then
  386. 14:18we're and then we can just pass in the
  387. 14:20receipt info so that we know uh exactly
  388. 14:22what kind of uh so that we know exactly
  389. 14:25what game pass failed from this decision
  390. 14:28okay and then finally we have to make
  391. 14:30sure to handle what happens if the
  392. 14:32purchase has not been granted we're
  393. 14:34basically just going to go down here and
  394. 14:36say return en. product purchas decision
  395. 14:42dot notprocessed yet so if none of this
  396. 14:46works in here like if the player does
  397. 14:48not exist uh if the Handler does not
  398. 14:50work then it's just going to go down
  399. 14:52here and return not processed yet so
  400. 14:55that Roblox can handle whatever is going
  401. 14:57to happen here so that the the player
  402. 14:59does not get charged If the product does
  403. 15:02fail so this is our basic structure for
  404. 15:05uh handling our developer product I hope
  405. 15:08this made sense to you so far but let's
  406. 15:10go back to our local script and I'm
  407. 15:12actually going to add a task. weight for
  408. 15:14like about 2 seconds so that uh the game
  409. 15:17gives me enough time to load into the
  410. 15:18game so now we're going to go into the
  411. 15:20game and see the result of this prompt
  412. 15:23that's being um shown right here okay so
  413. 15:25it says right here would you like to buy
  414. 15:27my first product I'm going to
  415. 15:29uh click this and then what's going to
  416. 15:30happen is the purchase has been success
  417. 15:33the purchase has been successful now if
  418. 15:35I run you can see that I'm actually
  419. 15:37moving faster now because I bought the
  420. 15:40game pad because I bought the developer
  421. 15:42product um compared to my walk speed
  422. 15:45being 16 the walk speed now should be uh
  423. 15:50the walk speed should now be 66 as you
  424. 15:52can see right here because I
  425. 15:53successfully bought the developer
  426. 15:55products so it's pretty much working as
  427. 15:56expected and that's how you handle uh
  428. 15:58developer product purchases in your
  429. 16:00Roblox game okay now let's say we wanted
  430. 16:02to get product information for a
  431. 16:05specific developer product so that we
  432. 16:06can use it to either um know what
  433. 16:10information this product does have uh or
  434. 16:12we could just display it in our game if
  435. 16:14we have the information to the product
  436. 16:16itself what we can do is go to our local
  437. 16:18script and we can basically just use a
  438. 16:21function that Marketplace service has
  439. 16:23called get product info uh pass in our
  440. 16:25product ID so that we can uh get back a
  441. 16:28table full of information about it so
  442. 16:30here's what we're going to do we're
  443. 16:31going to wrap this in a call by saying
  444. 16:33local success comma product info equals
  445. 16:38P call
  446. 16:40function function open close parentheses
  447. 16:43enter and then we're simply just going
  448. 16:45to return Marketplace service colon get
  449. 16:49product info open and close parentheses
  450. 16:52so we're first going to pass in our
  451. 16:54product ID over here and then we need an
  452. 16:57info type and this takes in an and and
  453. 17:00this takes in an enum info type so we're
  454. 17:02basically just going to say en. infotype
  455. 17:06and as you can see there's a lot of
  456. 17:07things we can select from uh what we are
  457. 17:09interested in is product because that is
  458. 17:12the product type that we are looking for
  459. 17:14in this case so now that we have our
  460. 17:16product type let's basically just go so
  461. 17:19now that we have our product type if we
  462. 17:21want to know what's inside of this table
  463. 17:23uh we can just Loop through all of the
  464. 17:25keys and values that are inside of this
  465. 17:27table so we're just going to say for key
  466. 17:30comma value in pairs open and close
  467. 17:33parentheses product info do oh sorry I
  468. 17:37forgot to put the do there uh we're just
  469. 17:38simply going to print key comma value
  470. 17:42just like this so now that we have this
  471. 17:44let's go into the game and hit play so
  472. 17:47what should happen is after about 2
  473. 17:48seconds it should print out all of the
  474. 17:50information of the developer products
  475. 17:53that we created in this game so we have
  476. 17:55something like the asset type the target
  477. 17:56ID um the minimum membership when it was
  478. 18:00created is limited is for sale there
  479. 18:02there's a whole bunch of stuff we can
  480. 18:04look at here uh for this product
  481. 18:06information so that is how you can
  482. 18:08access product information about a
  483. 18:10specific developer product if you need
  484. 18:12to use this in your game so for this
  485. 18:13last part of the video it's actually a
  486. 18:15pretty important one and that is keeping
  487. 18:17track of our purchase history for each
  488. 18:19player playing the game and the reason
  489. 18:21this is very important is because this
  490. 18:23is the only way we know if a player has
  491. 18:27actually bought a product or not because
  492. 18:28Roblox isn't going to do it themselves
  493. 18:30automatically it's up to us as the
  494. 18:32developers to be able to keep track of
  495. 18:34the purchase history that the player
  496. 18:36does have and it's not as intuitive as
  497. 18:38game passes so it's going to be a little
  498. 18:41tricky to um keep track of player
  499. 18:43history so I'm going to try and walk
  500. 18:45through so that you can understand how
  501. 18:47this stuff works so here's what we're
  502. 18:49going to do we're going to go to our
  503. 18:50script and at the very top we're going
  504. 18:52to get access to the data store uh
  505. 18:55service we're going to say local data
  506. 18:58store service equals game get service
  507. 19:02data store service and then we're going
  508. 19:05to access um our p and we're going to
  509. 19:09make a purchase history data store so
  510. 19:11we're just going to say local purchase
  511. 19:14history equals data store service colon
  512. 19:18get data store open and close
  513. 19:21parenthesis and we're going to call this
  514. 19:24purchase history so now we're going to
  515. 19:26come down here and make a few
  516. 19:28modifications to our process receipt uh
  517. 19:31call back the first thing we're going to
  518. 19:32do is figure out how we're going to
  519. 19:34structure our data store to know if the
  520. 19:36player has bought this uh product with
  521. 19:39like this specific transaction that
  522. 19:41they've done uh with receipt info uh
  523. 19:44there's a property here that's called
  524. 19:46receip
  525. 19:47info. purchase ID so this is essentially
  526. 19:50a value that is very unique to this
  527. 19:54specific purchase that this player is
  528. 19:55making so it would be a product that
  529. 19:58this player bought at this specific time
  530. 20:01and like anything else that ties into
  531. 20:03this specific uh purchase ID that has
  532. 20:05been um generated for us with this
  533. 20:08receipt so this is what we're going to
  534. 20:10use to determine a this so this is what
  535. 20:13we're going going to use to determine
  536. 20:15this specific transaction that this
  537. 20:17player has made so we're going to delete
  538. 20:19this so what we need to do is create a a
  539. 20:22player product ID for this specific
  540. 20:25transaction that this player is making
  541. 20:27so what we're going to do drop two lines
  542. 20:28and say local player product key and
  543. 20:33sorry I meant to say key not ID like
  544. 20:35this is going to be the key used for our
  545. 20:37data store so we're going to set this
  546. 20:40equal to a key that looks something like
  547. 20:43this we're going to say user ID dot dot
  548. 20:46for concatenation and then we're going
  549. 20:48to put in an underscore and then dot dot
  550. 20:50we're going to concatenate this again
  551. 20:53with the receip info. purchase ID so the
  552. 20:57way this is going to be structured is
  553. 20:58we're going to have our player's user ID
  554. 21:00and then this is going to be separated
  555. 21:01with uh the purchase ID the unique ID of
  556. 21:05the receipt that of the product that
  557. 21:07we're buying and so now down here we're
  558. 21:09going to uh make a PE call so that we
  559. 21:11can use get async with the data store so
  560. 21:13that we know that we're trying to
  561. 21:15retrieve this exact information from
  562. 21:17here so we're going to say local success
  563. 21:20error message equals P call function
  564. 21:24open and close parentheses enter and
  565. 21:27then what we we're going to do is in
  566. 21:29order to determine whether this actually
  567. 21:30was successful or not we're just going
  568. 21:32to make another variable up here by
  569. 21:34saying local purchased equals false and
  570. 21:38then we're going to set purchased down
  571. 21:41here equal to the get async function
  572. 21:44we're going to say purchase history
  573. 21:47colon get a sync open and close
  574. 21:50parenthesis and as the key it's going to
  575. 21:52be our player product ID like this and
  576. 21:57so once we do do this we're going to
  577. 21:58check if this was successful so we're
  578. 22:00going to say if success then but not
  579. 22:02just success we're also going to say if
  580. 22:05the purchase was successful as well then
  581. 22:07what we're going to do is simply just
  582. 22:09return the purchase granted down here
  583. 22:12regardless because if we know that this
  584. 22:14is already in the data store then we
  585. 22:16already know that this is a successful
  586. 22:18purchase so we don't have to do anything
  587. 22:20else after that so we're just going to
  588. 22:22pass it in just like that and uh this
  589. 22:24should be said uh player product key
  590. 22:26instead of ID my mistake
  591. 22:28and then what we're going to do is say
  592. 22:30else if not success so if this was not
  593. 22:34successful then what we're going to do
  594. 22:35is simply just print out an error
  595. 22:36message by saying um purchase has not
  596. 22:41been
  597. 22:43successful just like that I hope this
  598. 22:45part makes sense to you when we are
  599. 22:48determining the key for this purchase
  600. 22:50history it's basically going to be the
  601. 22:52players's user ID with the purchase ID
  602. 22:54of this specific transaction and we're
  603. 22:56going to check inside of this purchase
  604. 22:58history data store if this does exist
  605. 23:00and if this and if it does exist then
  606. 23:03we're basically going to return the
  607. 23:04value that's passed back from the
  608. 23:06purchase history using this product key
  609. 23:09and purchase is determined by either
  610. 23:10true or false so false is if it doesn't
  611. 23:13exist already and true if it already
  612. 23:15does exist in the data store so that's
  613. 23:17why we check if it's successful and if
  614. 23:18it's also been purchased already then
  615. 23:20we're just going to say that purchase
  616. 23:21has been granted we don't need to we
  617. 23:23don't need to do anything else after
  618. 23:24that but if it was not successful then
  619. 23:26we're just going to say that purchase
  620. 23:28has not been successful so that's only
  621. 23:29one part of it but that is an important
  622. 23:32part that we need to add into our script
  623. 23:34and I hope this part has made sense to
  624. 23:37you at least so far well since we do
  625. 23:38have an error message we actually could
  626. 23:40just concatenate this um with the error
  627. 23:43message down here so we can just say
  628. 23:45error message like this because we we
  629. 23:47basically just have it right here uh so
  630. 23:50this is basically the so this is
  631. 23:52basically one way we can tell more
  632. 23:54information about this error message if
  633. 23:56it does ever come down here okay so we
  634. 23:58have the script down here that basically
  635. 24:00gives the benefits to the player if they
  636. 24:02buy a specific product but what we need
  637. 24:04to do now is wrap this in a PE call uh
  638. 24:07by first checking if this purchase is
  639. 24:11already in the data store if this
  640. 24:13purchase was already granted to the
  641. 24:15player so that the script doesn't
  642. 24:16randomly just duplicate the benefits for
  643. 24:19the player if they accidentally do buy
  644. 24:20it twice and we're going to do a second
  645. 24:23check to make sure that this product has
  646. 24:25already been granted to the player uh
  647. 24:28and we're going to utilize this using
  648. 24:30update async if you remember that with
  649. 24:32data Stores um this is how it's going to
  650. 24:35look we're going to drop a line down
  651. 24:36here before we declare player we're
  652. 24:38going to say local success comma is
  653. 24:42purchase recorded equals P call function
  654. 24:46open and close parentheses enter and
  655. 24:48then for this Boolean right here is
  656. 24:51purchase recorded we're going to set
  657. 24:53this equal to a return value given by
  658. 24:56this data stores up update async
  659. 24:58function so this is basically what it's
  660. 25:01going to look like uh you can just copy
  661. 25:02what I do and I'll explain what's going
  662. 25:03to happen here we're going to say return
  663. 25:06purchase history colon update async open
  664. 25:11and close parentheses we're going to
  665. 25:12pass in the key of the player product
  666. 25:17key and then we're going to um and then
  667. 25:20the second argument is going to be a
  668. 25:22function with a past parameter in here
  669. 25:25called already purchased
  670. 25:28and then we're going to hit enter like
  671. 25:29this we're going to check if already
  672. 25:32purchased is true then we're just simply
  673. 25:35going to return true and then there's
  674. 25:38going to be more things we're going to
  675. 25:40do down here in just a little bit but
  676. 25:41first I want to explain what's happening
  677. 25:43here with this code snippet so we're
  678. 25:45basically creating another PE call with
  679. 25:47is purchase recorded this is going to be
  680. 25:49a Boolean that we're going to return and
  681. 25:51we're going to set this equal to a p
  682. 25:53call function of this return value
  683. 25:56that's going to be set to is purchase
  684. 25:58recorded uh from this update async
  685. 26:02function um so essentially What's
  686. 26:04Happening Here is with this player
  687. 26:06product key this key in particular with
  688. 26:09this purchase history if this gets
  689. 26:11updated like let's say the value for um
  690. 26:15let's say the value for this product key
  691. 26:17inside a purchase history gets updated
  692. 26:19like the value gets updated is we're
  693. 26:21going to create a new function with a
  694. 26:24past argument already purchased uh to
  695. 26:27then have some sort of return value
  696. 26:29inside of this update async function to
  697. 26:32then be placed back into is p is
  698. 26:35purchase recorded because as you know if
  699. 26:37we take the player product key put it
  700. 26:39inside a purchase history get the value
  701. 26:42from that key in the purchase history
  702. 26:45that value is going to be placed into
  703. 26:48the function parameter here inside of um
  704. 26:51inside of the inside of the parameter
  705. 26:54for this function that we just created
  706. 26:55already purchased already purchased is
  707. 26:58the value of whatever we got from the
  708. 27:01purchase history using this player
  709. 27:02product key I hope that part made sense
  710. 27:05to you and it's important that you do
  711. 27:06understand that part so if we see if the
  712. 27:09purchase has already been successful
  713. 27:10then we're simply just going to return
  714. 27:11true and if not then we're going to
  715. 27:13continue doing more checks down here so
  716. 27:15literally what we're going to do is take
  717. 27:17this code snippet with uh the granting
  718. 27:19the benefits for the player we're going
  719. 27:21to we're going to cut this paste it down
  720. 27:23here and then we're also going to return
  721. 27:26true down here as well like at the very
  722. 27:29endend of this update async function for
  723. 27:32the is Rec is purchase recorded Boolean
  724. 27:35but since we've structured this a little
  725. 27:36differently since we're going to return
  726. 27:38true no matter what instead what we're
  727. 27:40going to do is return a Boolean of false
  728. 27:44if uh any of these checks go wrong so
  729. 27:47instead of this if else statement right
  730. 27:50here what we're going to do instead is
  731. 27:51say if not success or not result
  732. 27:58then we're going to throw in an error
  733. 28:01saying purchase has been
  734. 28:05unsuccessful and then we can write down
  735. 28:07the product that failed so we're just
  736. 28:09going to say receip info. product ID and
  737. 28:14now there's one final step and that is
  738. 28:16determining the product decision because
  739. 28:19we're not just going to rely on this
  740. 28:21just being not processed yet all the
  741. 28:24time uh so we're just going to delete
  742. 28:26this and what we're going to do instead
  743. 28:28is make an if else if else structure
  744. 28:31here so the first thing we're going to
  745. 28:32do is check if it was not
  746. 28:34successful like if um like if this
  747. 28:38variable if this success variable here
  748. 28:40was just not successful then what we're
  749. 28:42going to do is give an error by saying
  750. 28:45uh purchase data store has been
  751. 28:50unsuccessful something like that uh and
  752. 28:52then we're going to return an en.
  753. 28:55product purchase decision do
  754. 28:58notprocessed yet and then we can make
  755. 29:01another else if is purchased recorded
  756. 29:05equals nil so what this means is if the
  757. 29:08purchase that we did like if there was
  758. 29:10no value that was updated in the data
  759. 29:12store was changed then we're basically
  760. 29:14going to also return not processed yet
  761. 29:17because there is an issue going on with
  762. 29:18that and then if both of these are not
  763. 29:21the case then that means the purchase
  764. 29:23has been successful so we're going to
  765. 29:24say uh
  766. 29:26return uh we're basically just going to
  767. 29:28take this and then we're going to return
  768. 29:30purchase granted okay that was kind of a
  769. 29:34lot to take in but we have finished our
  770. 29:37product we have finished our data store
  771. 29:40script for handling uh all of these
  772. 29:43different scenarios that we might have
  773. 29:45when it comes to handling our developer
  774. 29:47product purchases it's very it is kind
  775. 29:49of sophisticated at first but if you do
  776. 29:51understand what's happening here with
  777. 29:52the script then you'll have a much
  778. 29:55better time implementing this in the
  779. 29:56future especially when you incorporate
  780. 29:58more game passes uh and you decide to
  781. 30:01work more analytically with uh all of
  782. 30:04these purchases that are happening in
  783. 30:05your game so that is basically
  784. 30:07everything that has to do with developer
  785. 30:09products and I hope you found this video
  786. 30:10to be very informative like I said I
  787. 30:11hope you found this video to be very
  788. 30:13informative it was a bit longer than I
  789. 30:14thought but that's because I want you to
  790. 30:16get a full grasp of how data I want you
  791. 30:19to get a full grasp of how these things
  792. 30:21work because I know data stores is one
  793. 30:23of the most uh confusing topics to new
  794. 30:25developers and so I wanted to to take
  795. 30:27the time to go through step by step on
  796. 30:30my understanding of using data stores uh
  797. 30:33with developer products and things like
  798. 30:34that so if you want to refresh your
  799. 30:37memory on the basics of data stores then
  800. 30:39I will link to my data stores video that
  801. 30:41I'll have for you right here in this
  802. 30:43video but with that being said I hope
  803. 30:45you found this video to be helpful and I
  804. 30:47will see you in the next episode take
  805. 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.