YouTube2Text

Scripting the Gamepass Shop Gui! Roblox Studio Simulator Guide Episode 22 — Transcript

by MonzterDEV · 7,776 words · 1,027 segments · language en · Watch on YouTube

Full transcript

  1. 0:00welcome back to the simulator series in
  2. 0:01today's episode we are going to be
  3. 0:02scripting the game pass shop gui that we
  4. 0:04made in the last episode as always if
  5. 0:06you guys do enjoy the video or does help
  6. 0:07you out make sure you smash the like
  7. 0:08button also the subscribe button and
  8. 0:10turn this post notifications on if you
  9. 0:11want to get notified when i upload more
  10. 0:12roblox development content additionally
  11. 0:14i do with patreon if you guys like this
  12. 0:16for me and gain access to all the
  13. 0:17scripts and the game file like during
  14. 0:18this episode there's a link down below
  15. 0:19in description and you guys can go and
  16. 0:20check that out to showcase the
  17. 0:22functionality of the gui when we go into
  18. 0:24eating simulator we can click on the
  19. 0:25shop button which will pop up with the
  20. 0:27shop gui then inside of here we have
  21. 0:29four different buttons which we can
  22. 0:30click the passes which displays all the
  23. 0:32passes the ultra patch which displays
  24. 0:34the patch for sale the coins which
  25. 0:36displays a couple of coin packages for
  26. 0:37sale and then finally boost which
  27. 0:39displays the boost for sale as well now
  28. 0:41with the boost whenever we click on one
  29. 0:42of these buttons for example it will pop
  30. 0:44up with a developer product which we can
  31. 0:46purchase the same goes for the passes if
  32. 0:48we click on any of these passes it will
  33. 0:49allow us to purchase them so hopping
  34. 0:51back into studio where we left off last
  35. 0:53time let's go into the starter gui and
  36. 0:55we have our game pass shop now we'll
  37. 0:56explain this a little bit one of the
  38. 0:58things i want to quickly change that we
  39. 0:59didn't do last time was if we look
  40. 1:01inside of all of our containers we have
  41. 1:03something in them called template the
  42. 1:04only container that we actually don't
  43. 1:06have something called template inside is
  44. 1:08the boost container so what we want to
  45. 1:10quickly do is rename this frame from
  46. 1:12frame to template we then want to script
  47. 1:14this button right here which will be the
  48. 1:16button that we can click to actually
  49. 1:17display the shop now we already did
  50. 1:19something very similar to this with the
  51. 1:20settings and if we look inside of this
  52. 1:22bun script right here we actually have
  53. 1:24the exact functionality that we also
  54. 1:25want to have for the game pass button so
  55. 1:27what we're going to do is we're simply
  56. 1:28just going to copy this and we're going
  57. 1:30to paste it directly into the game shop
  58. 1:31gui then let's go ahead and open up the
  59. 1:33script and now we see we have the buns
  60. 1:35gy which refers to this gui right here
  61. 1:37so inside of the buttons holder this
  62. 1:39time we need the shop bun instead of the
  63. 1:41settings button so we have the settings
  64. 1:42button right here let's replace that
  65. 1:44with shop and then all we have to do is
  66. 1:46replace the settings button with shop
  67. 1:48button boom boom there we go and now
  68. 1:50whenever we click on this it will enable
  69. 1:52the screen gy and the screen gui refers
  70. 1:55to the parent which would be the game
  71. 1:56pass shop we go ahead and test this out
  72. 1:58by starting up our game clicking on the
  73. 2:00button and we can see it pops up when we
  74. 2:02click it or it closes if it's already
  75. 2:03opened when we click the button the next
  76. 2:05thing we want to do is we want to head
  77. 2:06inside of the replicated storage inside
  78. 2:07of our config folder and we want to
  79. 2:09create a module script which will hold
  80. 2:10the configurations for all of our
  81. 2:12different game passes and developer
  82. 2:13products so what we're going to do is
  83. 2:15we're just going to simply insert a
  84. 2:16brand new module script and we'll rename
  85. 2:18this to game pass shop now remember we
  86. 2:20have four different categories in our
  87. 2:22shop so we're going to be making four
  88. 2:24different configuration tables inside of
  89. 2:26this one module script for each of the
  90. 2:28different categories the first category
  91. 2:29that we'll create a config for will be
  92. 2:31the passes so we're going to say
  93. 2:33module.passes and then we're going to
  94. 2:34create a table and we're going to use
  95. 2:36this as an array so we're going to
  96. 2:37create another table inside of here and
  97. 2:39this is going to be one of the config
  98. 2:40lines so one of the properties that each
  99. 2:42of our game pass is going to have is
  100. 2:43going to be the id and for the first
  101. 2:45pass it's going to be infinite
  102. 2:47underscore food then the second property
  103. 2:49is going to be the price so how much
  104. 2:51robux is it gonna cost and we're gonna
  105. 2:53say
  106. 2:54799 then the last property we're gonna
  107. 2:56create for now is going to be the image
  108. 2:58property and we're just gonna set that
  109. 2:59to a blank string now if you're using a
  110. 3:01specific image for each individual game
  111. 3:03pass then you would put the url to the
  112. 3:05image directly here then we're going to
  113. 3:07add a comma at the end of this and we're
  114. 3:08just going to duplicate this line three
  115. 3:10times and we'll just modify some of
  116. 3:11these properties for a couple of other
  117. 3:13game passes so the second game pass that
  118. 3:14we're gonna have is times two underscore
  119. 3:17food that is going to cost
  120. 3:19549 and then the third one is going to
  121. 3:21be vip and that will cost 449. now let's
  122. 3:24go back inside of the gamepad shop gui
  123. 3:27and we'll add a new local script and
  124. 3:29we're just going to call this handler
  125. 3:30now what we're going to do is we're
  126. 3:31going to create the generator now what
  127. 3:33we're going to do is we're going to
  128. 3:34create a generator for this shop and
  129. 3:36what i mean by that is we're going to
  130. 3:37create a function and we're going to
  131. 3:39loop through all the passes in our
  132. 3:40config file and we're going to take this
  133. 3:42information and we're going to use that
  134. 3:44information along with the specific
  135. 3:45templates to populate our gui it's the
  136. 3:48exact same method that we use when
  137. 3:49creating the settings gui so you guys
  138. 3:51should be already familiar with this
  139. 3:53anyways inside of the handler we're
  140. 3:54going to get the replicated storage
  141. 3:56additionally we are going to want to
  142. 3:57require the game pass shop config that
  143. 3:59we just made now that we have that let's
  144. 4:00start creating a couple of variables for
  145. 4:02the gui and the frames inside of it so
  146. 4:04we're going to say local screen gui
  147. 4:06equals script dot parent then we want to
  148. 4:09get the frame so frame equals screen gui
  149. 4:12dot frame then since we're first gonna
  150. 4:14generate the passes category let's go
  151. 4:16ahead and get the passes container so
  152. 4:18we're gonna say local passes container
  153. 4:21equals frame dot passes container and
  154. 4:24then we also wanna get the passes
  155. 4:25template as well so we're gonna say
  156. 4:26local passes template equals passes
  157. 4:29container dot template additionally
  158. 4:31let's go ahead and initialize the exit
  159. 4:33button as well so we're gonna say local
  160. 4:35exit equals frame dot exit button and we
  161. 4:38can script that really quick so we'll
  162. 4:39say exit dot mouse button one click
  163. 4:41connect function and then screen gui dot
  164. 4:44enabled equals false so that makes the
  165. 4:46screen gy invisible whenever we click
  166. 4:48the exit button next let's go ahead and
  167. 4:50create a function inside of here and
  168. 4:51we're gonna call that generate and we're
  169. 4:53gonna call the first parameter info and
  170. 4:55that's actually going to be a table the
  171. 4:57next argument is going to be called
  172. 4:58template and that's actually going to be
  173. 5:00either a text button or a frame and
  174. 5:02remember the passes template is actually
  175. 5:04a text button but if we remember
  176. 5:06correctly the boost template is actually
  177. 5:08a frame that's why we're saying either a
  178. 5:09text button or a frame and of course you
  179. 5:11guys don't have to add the type checking
  180. 5:12here like i am you could simply just
  181. 5:15write that and not type check at all but
  182. 5:17i like to do type checking because i
  183. 5:18think it really helps and then the final
  184. 5:20argument is going to be the container
  185. 5:22where we're going to store the generated
  186. 5:23templates at and that's going to be a
  187. 5:25scrolling frame so now we have all the
  188. 5:26arguments for that function we then want
  189. 5:28to create a variable for cloning the
  190. 5:29template so we're going to say local
  191. 5:31clone equals template remember the
  192. 5:33template that we're passing through
  193. 5:35cologne then we're going to set the
  194. 5:36parent of the clone to the container
  195. 5:38which we also passed through here now
  196. 5:40let's open up the frame and let's go
  197. 5:42inside of passes for right now so we
  198. 5:43have the template right here so first
  199. 5:45we're gonna set the name of the template
  200. 5:47which would be a text button to the
  201. 5:50info.id and remember info dot id for an
  202. 5:53example would be infinite underscore
  203. 5:55food and that's what the name of the
  204. 5:56text button is going to be set to then
  205. 5:58inside of the template we have a text
  206. 5:59label called title we're going to modify
  207. 6:01the text of that text label and we're
  208. 6:03going to set it to the info dot id and
  209. 6:05remember when we created the settings
  210. 6:07generator we use the function on the
  211. 6:09string called g sub and what that does
  212. 6:11is it replaces a specific character or
  213. 6:13string with another specific character
  214. 6:14or string that you want it to so we want
  215. 6:16to replace the underscore with a space
  216. 6:18and the reason that we're doing that is
  217. 6:20for infinite underscore food that will
  218. 6:22just be infinite space food which is how
  219. 6:24we want it to be displayed then we also
  220. 6:26have the price label so we're going to
  221. 6:27say clone.price.txt
  222. 6:29equals
  223. 6:30info.price and finally we have the image
  224. 6:33label and we're going to say
  225. 6:34clone.image.image
  226. 6:36because remember this refers to the
  227. 6:38image label and then image if we look
  228. 6:40inside of image we can see that the
  229. 6:42image label named image has a property
  230. 6:44also named image so we can say
  231. 6:46clone.image.image
  232. 6:48equals and then we will say the
  233. 6:50info.image and remember the info id
  234. 6:53price and image all come from this
  235. 6:55specific configuration line right here
  236. 6:57and then finally what we want to do is
  237. 6:58we want to set the clone to be visible
  238. 7:01so the player can actually see it and
  239. 7:02then whenever the player clicks on this
  240. 7:04we also want to do something as well so
  241. 7:05we're going to say clone dot mouse
  242. 7:07button one click colon connect function
  243. 7:11and for right now we are just going to
  244. 7:12print true so that we know that it was
  245. 7:14clicked now that we have the basic
  246. 7:16generator created we actually need to
  247. 7:17loop through a table inside of our
  248. 7:19config and use the generator and we'll
  249. 7:21do this by saying for underscore info in
  250. 7:24pairs config dot and for this example
  251. 7:28we're going to be using passes so we're
  252. 7:29going to say dot passes do and then
  253. 7:31we're just simply going to call generate
  254. 7:33and we'll pass through info which is
  255. 7:35going to be the config table and then
  256. 7:36for the template and the container we
  257. 7:38want to use the passes template and the
  258. 7:41passes container now the last thing that
  259. 7:42we want to do just so that we can
  260. 7:43quickly test this out is we want to make
  261. 7:46the passes container visible so we can
  262. 7:48actually see this and let's also set
  263. 7:50this template to not visible so that we
  264. 7:52don't see the blank template that we're
  265. 7:53not actually using then we can go ahead
  266. 7:55start up our game and make sure this
  267. 7:56works all correctly and as we see we see
  268. 7:58infinite food two times food and vip
  269. 8:01have all been generated we can see their
  270. 8:02prices are correct and their image is
  271. 8:04correct as well because our image is
  272. 8:06just a blank string which means that
  273. 8:07there's no image currently additionally
  274. 8:09if we click on them we can see true has
  275. 8:10been printed the console and that means
  276. 8:12that everything is working exactly as we
  277. 8:14wanted to now that was one of the harder
  278. 8:16parts but we're still gonna have to
  279. 8:17customize this in the future to be
  280. 8:19tailored towards every single container
  281. 8:20this is currently only tailored
  282. 8:22specifically towards the passes
  283. 8:23container and we'll modify this more in
  284. 8:25the future so that it works with all the
  285. 8:27containers that we have what we now want
  286. 8:28to work on is the shop categories bun
  287. 8:30and making them functional so underneath
  288. 8:32our frame right here let's go ahead and
  289. 8:33set a variable for the category frame
  290. 8:35and we're actually going to rename the
  291. 8:36category frame from category frame to
  292. 8:38just category so we're going to say
  293. 8:39local category equals frame dot category
  294. 8:42additionally underneath of the exit
  295. 8:44button we're going to create a new
  296. 8:46variable called current category and
  297. 8:48we're just going to set that to passes
  298. 8:50as that's the first category that we
  299. 8:51want to display to the player because
  300. 8:53that's our first button the next thing
  301. 8:54we want to do underneath the for loop
  302. 8:56where we currently are generating passes
  303. 8:58at we want to make another for loop and
  304. 8:59this time we're actually going to loop
  305. 9:00through the category frame and get all
  306. 9:02of the different buttons so we're going
  307. 9:04to say for underscore comma button in
  308. 9:07ipairs category get children do then
  309. 9:10what we're going to do is we're going to
  310. 9:11say button.mousebutton
  311. 9:14one click so whenever we click on a
  312. 9:16button we want to do something and for
  313. 9:19right now we'll just say print true for
  314. 9:21example but the thing is is that if we
  315. 9:22actually ran this we would come up with
  316. 9:24an error because mouse button one click
  317. 9:26is not an event of the ui grid layout
  318. 9:29and remember we're getting all of the
  319. 9:30categories children and these are all
  320. 9:33the category children right here so we
  321. 9:35pretty much need to filter out the ui
  322. 9:37grid layout and one simple and easy way
  323. 9:39to do that is by saying if not button
  324. 9:41and then we're going to use is a and
  325. 9:43then we say what we want it to be so we
  326. 9:45want them to be text buttons so we're
  327. 9:48saying if it is not a text button then
  328. 9:49what we're going to do is we are going
  329. 9:51to continue through the loop end and now
  330. 9:53this is all on one line another way to
  331. 9:55format this which you might be more
  332. 9:57familiar with is this way this is
  333. 9:58normally how if statements are written
  334. 10:00but you guys have seen me write if
  335. 10:02statements on one line before so it
  336. 10:04shouldn't be too new but what this is
  337. 10:05saying is while looping through this if
  338. 10:07the button is not actually a text button
  339. 10:09then we're going to completely ignore
  340. 10:10that item and just continue through the
  341. 10:12loop so we're basically stopping the
  342. 10:13code before it gets to this part and
  343. 10:15we're doing that so that when it's a ui
  344. 10:17grid layout it stops right here before
  345. 10:18it actually gets to the mouse button one
  346. 10:20click because that would throw an error
  347. 10:22so i'm going to undo what i just did
  348. 10:23right there and just keep it all on one
  349. 10:25line and it looks very clean now we want
  350. 10:27to create another function underneath of
  351. 10:28the generate function that we have and
  352. 10:30this function is going to be called
  353. 10:32display and what we're going to accept
  354. 10:34is the category which is going to be a
  355. 10:36string and then what we're going to do
  356. 10:38is with this for loop every single time
  357. 10:40we click the button what we want to do
  358. 10:42is we want to call the display function
  359. 10:44and we want to pass through the buttons
  360. 10:46name now the reason for that is because
  361. 10:48if we look at the buns we have a button
  362. 10:49called boosts coins passes and pets and
  363. 10:52if you look at our containers the names
  364. 10:54of the containers are also coins passes
  365. 10:57pets and boosts so if you're not getting
  366. 10:58the big picture yet just keep following
  367. 11:00along don't worry what we first want to
  368. 11:02do is we first want to check if the
  369. 11:03current category which remember is the
  370. 11:05variable that we set up here is the same
  371. 11:08as the category which just got passed to
  372. 11:10this function and if that's true then we
  373. 11:12don't want to do anything so we're just
  374. 11:14going to say then return end which
  375. 11:16basically prevents anything from below
  376. 11:18this line from running and the reason
  377. 11:19that we're doing that is because for
  378. 11:20instance if the player is on the passes
  379. 11:22page and they click the passes button we
  380. 11:24don't need it to do anything so it
  381. 11:26shouldn't then what we want to do is we
  382. 11:27want to create a new variable and we're
  383. 11:29going to call this currentcontainer and
  384. 11:31we want to set that to frame find first
  385. 11:34child and then we want to pass through
  386. 11:36the current category dot dot which we
  387. 11:38use to combine a string and the string
  388. 11:40is going to be container so imagine the
  389. 11:42current category equals passes what
  390. 11:44we're going to do is we are going to
  391. 11:45look inside of the frame which let's see
  392. 11:48this is the frame and then inside of the
  393. 11:49frame we're looking for passes container
  394. 11:52and that'll find the scrolling frame
  395. 11:53right here and then we can do something
  396. 11:55with this now what we want to do with
  397. 11:56the found frame is we want to set the
  398. 11:58visibility of it to false so the player
  399. 12:01no longer sees it after we do that we
  400. 12:03then want to set the current category to
  401. 12:05the new category that we just passed to
  402. 12:07the function and we're actually going to
  403. 12:08do the exact same thing so we can
  404. 12:10literally copy this line right here
  405. 12:12don't copy the local though and we're
  406. 12:14once again gonna set the current
  407. 12:15container to the frame find first child
  408. 12:17and now the new container because
  409. 12:19remember we're setting current category
  410. 12:20to the new category that we're passing
  411. 12:22through right here and then we're gonna
  412. 12:23do the exact same thing we're gonna find
  413. 12:25the new container frame and then once we
  414. 12:27do that we wanna set the current
  415. 12:28container frame to visible so the player
  416. 12:31can actually see it so to recap what's
  417. 12:33going on here whenever we click on any
  418. 12:35of these buttons we're gonna call the
  419. 12:36display function with the name of that
  420. 12:39button and if we click on a page that
  421. 12:40we're not already looking at then we're
  422. 12:42gonna find the container that we're
  423. 12:43already looking at we're gonna make that
  424. 12:45not visible and then we're gonna set the
  425. 12:46same variable to the new category that
  426. 12:49we wanna look at and then we're gonna
  427. 12:50find the new container frame and we're
  428. 12:51gonna make that visible so we can see it
  429. 12:53so pretty much hide the old one and show
  430. 12:55the new one so let's go ahead start up
  431. 12:57our game and test this out by clicking
  432. 12:58on ultra pets we can now see that this
  433. 13:00is displayed and remember we still need
  434. 13:02to set all the templates to not be
  435. 13:04visible except for the passes but now
  436. 13:05when we click on passes we only see the
  437. 13:07generated passes when we click on ultra
  438. 13:09pets we only see the ultra pets when we
  439. 13:11click on coins we only see coins and
  440. 13:12then when we click on boost we only see
  441. 13:14boost so that is working perfectly and
  442. 13:16if we click on the same button that
  443. 13:17we're already looking at nothing happens
  444. 13:19it's all working exactly as it should be
  445. 13:21with that all being said up the next
  446. 13:22thing that we want to do is we want to
  447. 13:23head back to our game pass config file
  448. 13:25and let's add another category to this
  449. 13:27so what we can do is we can copy our
  450. 13:28passes category and then paste it right
  451. 13:30below it this time we'll add the pets
  452. 13:32category so our first pet we're just
  453. 13:33going to use a random example for this
  454. 13:35it's going to be dog the second one will
  455. 13:37be cat and the third one will be turtle
  456. 13:39now for the price we are going to set it
  457. 13:40to the prices that they have it as so 19
  458. 13:43900
  459. 13:444999 and finally 2
  460. 13:472449. then for the image we're once
  461. 13:49again going to just leave those as blank
  462. 13:51strings but we're actually going to add
  463. 13:52a new property to this and that is going
  464. 13:54to be called stat and for the first one
  465. 13:56we're going to set that to 100 000. now
  466. 13:58the reason that we're adding the stat
  467. 13:59property to the pets is because if we
  468. 14:01remember it displays the pet stat at the
  469. 14:03top left hand corner of the template and
  470. 14:05the thing with this is that both the
  471. 14:07food stat and the money stat are both
  472. 14:08the exact same value so we don't need to
  473. 14:11make two separate stats but for instance
  474. 14:13if you wanted to you could say stat 1
  475. 14:15and then stat 2 and set that to a
  476. 14:18different value if you wanted to and you
  477. 14:20could easily add this to your own system
  478. 14:22it really wouldn't be that hard at all
  479. 14:23but we're keeping it consistent with how
  480. 14:25they have it so we are making one
  481. 14:26specific stack then we'll set the stat
  482. 14:28property for the second pet so stat
  483. 14:30equals 10 000 and then finally for the
  484. 14:33turtle the stat is equal to 4 000. now
  485. 14:36that we added all that we should now
  486. 14:37modify the generate function to
  487. 14:38accommodate for all those changes let's
  488. 14:40go ahead and open up our pet's container
  489. 14:42and look inside of the template so that
  490. 14:43we can see all the different things it
  491. 14:45has inside of it additionally we can
  492. 14:46open up the passes container and compare
  493. 14:48the two different templates the pet
  494. 14:50template doesn't actually have a title
  495. 14:52so inside of our generate function when
  496. 14:54we say clone.title we actually won't be
  497. 14:56able to use this for pets or else we're
  498. 14:58going to get an error so the first thing
  499. 14:59we want to do is inside of this function
  500. 15:01we want to say local title and actually
  501. 15:03create a variable for the title and
  502. 15:05we're going to set that to clone find
  503. 15:07first child and we want to find a child
  504. 15:10named title and then we'll say if title
  505. 15:12so if we find the title child then what
  506. 15:14we'll do is we'll do what we were
  507. 15:16already doing which is changing the
  508. 15:18title to a specific string now we're
  509. 15:19gonna basically do the same thing that
  510. 15:20we just did but for the food and money
  511. 15:22stat considering the other templates
  512. 15:24don't share the same child so what we're
  513. 15:27going to do is we're going to say local
  514. 15:28food stat equals clone find first child
  515. 15:32food stat and then we'll also create a
  516. 15:34variable for the money stat as well so
  517. 15:36we'll just replace food with money and
  518. 15:38there we go we now have both of those
  519. 15:40and then we're going to say if food stat
  520. 15:42and money stat we really only need to do
  521. 15:45one but we'll just do both because we
  522. 15:46might as well if we find both of them
  523. 15:48then we're going to set the food stat
  524. 15:50dot text to our food icon x and then
  525. 15:53we'll combine that with the
  526. 15:55info.stat so remember we just added the
  527. 15:58stat property to each table so that's
  528. 16:00where we're getting the stat from and
  529. 16:01we'll also do the same thing for the
  530. 16:02money stat so instead of the food logo
  531. 16:04we'll just do the money logo and we set
  532. 16:06that the exact same way additionally i
  533. 16:08realized they made a slight mistake when
  534. 16:10we set the price text we actually forgot
  535. 16:12to add on the r money symbol that they
  536. 16:14have onto there so there we go we now
  537. 16:16added that and now that we have all of
  538. 16:17that we can now generate exactly how we
  539. 16:19do with the passes for the pets so we
  540. 16:21can just copy and paste this and we can
  541. 16:23say pets and then we need to pass
  542. 16:25through the pets template and the pest
  543. 16:26container so let's initialize those
  544. 16:28variables up here we'll copy and paste
  545. 16:30that so pets container and then the pets
  546. 16:33template and then when we call the
  547. 16:34function we want to pass through the
  548. 16:36pets template and the pets container so
  549. 16:38there we go now let's start up our game
  550. 16:40and check it out also make sure that you
  551. 16:41set the template to not visible so that
  552. 16:43you don't see that and we're just going
  553. 16:45to set this container to not visible
  554. 16:46either because we want the first
  555. 16:47container to be the passes container but
  556. 16:49since we were debugging and stuff like
  557. 16:51that that's why the other one was
  558. 16:52visible anyway when we load in we now
  559. 16:54still see the passes loaded up which is
  560. 16:56perfect let's click on ultra pets and we
  561. 16:58now see that these have been created
  562. 16:59exactly as they should be they have the
  563. 17:01stat at the top left they have the price
  564. 17:03and then they would have the image if we
  565. 17:04did use one looking at the numbers
  566. 17:06though it does make me want to add the
  567. 17:07number formatter to this so let's go
  568. 17:09ahead and do that if you guys don't know
  569. 17:10what the number four matter is we
  570. 17:12actually added that a while ago when we
  571. 17:14were creating the shop it's basically a
  572. 17:15module that we're using and i'm just
  573. 17:17going to go back into our shot manager
  574. 17:18copy this and i will paste it directly
  575. 17:20into here so now we have the format
  576. 17:22number i'm going to rename it though so
  577. 17:24capital f and capital m for the format
  578. 17:26number since i don't exactly remember
  579. 17:27how to use it off the top of my head we
  580. 17:29can search for how to use it so we're
  581. 17:30going to use format compact exactly like
  582. 17:32how they do so let's find where we have
  583. 17:34our numbers at so for instance we have
  584. 17:36them at the price so we'll say format
  585. 17:38number dot format compact and then wrap
  586. 17:40our number inside of parentheses so
  587. 17:43there we go then we can copy this and
  588. 17:44we'll use that for the stat as well so
  589. 17:47just like that and then for the last
  590. 17:48stat as well so we can go ahead and
  591. 17:50start this up once again and make sure
  592. 17:51the numbers are now formatted correctly
  593. 17:53and we can see that if we go to the
  594. 17:54ultra pets we have 19k and 100k 10k 4k
  595. 17:58and exactly as we want them now if you
  596. 18:00guys want the format module or you guys
  597. 18:02want to know how to use it there are
  598. 18:03more ways of formatting your numbers
  599. 18:05i'll leave a link down below in the
  600. 18:06description to the number format module
  601. 18:08that i used and i introduced in previous
  602. 18:10episodes so that you guys can check it
  603. 18:11out for yourself so the next thing that
  604. 18:13we want to do is we'll go back to the
  605. 18:14config and we will add another category
  606. 18:16we're actually going to copy and paste
  607. 18:18the passes table once again because this
  608. 18:20time we'll actually be adding in the
  609. 18:21coined game pass and the coin game
  610. 18:23passes are nearly identical to the
  611. 18:25passes so for the first one we're going
  612. 18:26gonna say plus
  613. 18:28276.4 k underscore coins and the price
  614. 18:31of that is going to be 79. the second
  615. 18:33one is going to be 4.1
  616. 18:36m and the final one is going to be 15.2
  617. 18:39m and then for the prices the second
  618. 18:40one's going to be 179 and the third one
  619. 18:43is going to be 399. now we shouldn't
  620. 18:45have to make any changes to the generate
  621. 18:47so all we have to do is just add the
  622. 18:49variable for the coins container and the
  623. 18:51coins template as well we'll once again
  624. 18:53add an if statement for the coins and
  625. 18:55we'll pass through the coins template
  626. 18:57and the coins container and start up our
  627. 18:59game and make sure that those work as
  628. 19:01they should so if we click on coins we
  629. 19:02can see the coins are generated the only
  630. 19:04thing that we have to do is actually
  631. 19:05hide the initial template so go into the
  632. 19:07coins container let's go ahead and set
  633. 19:09the visibility of this to false now the
  634. 19:11final one which is slightly more
  635. 19:12complicated is we need to add in the
  636. 19:14boost config so for boost we'll just
  637. 19:16copy the coins template we'll just copy
  638. 19:18the quinn's config we'll paste it below
  639. 19:20pets and we will set this to boosts and
  640. 19:22now i'm just going to delete the other
  641. 19:23two boosts and we'll just make one first
  642. 19:25and then copy this two times the first
  643. 19:27one is gonna be times five underscore
  644. 19:29luck the price of it is going to be 149.
  645. 19:32now for boost if we look inside the
  646. 19:33template and we look at the prices we
  647. 19:35can see that each of them have three
  648. 19:37durations and that'll be 10 minutes 30
  649. 19:39minutes and then a one hour duration so
  650. 19:41we need to set three different prices
  651. 19:43for each of the boosts so for boost
  652. 19:45we're gonna say price one and this would
  653. 19:47be the price for the ten minute boost
  654. 19:48and we're going to set that to 149 then
  655. 19:51for price 2 which would be the 30 minute
  656. 19:52boost we're gonna set that to 399 and
  657. 19:55then for price three which would be one
  658. 19:56hour we're gonna set that to 699. then
  659. 19:59we will duplicate this two times then
  660. 20:01we're going to say times 50 underscore
  661. 20:04food and times five underscore coins now
  662. 20:06the price for 50 food is the same as the
  663. 20:09luck but for the five times coins the
  664. 20:10first one is gonna be 49 the second one
  665. 20:12is going to be 99 and the third one is
  666. 20:14going to be 149. now that we have this
  667. 20:16we once again need to modify the
  668. 20:17generate function to accommodate the
  669. 20:19brand new config now there's a couple
  670. 20:20things that are different about the
  671. 20:21boost templates compared to all the
  672. 20:23other templates the first difference is
  673. 20:25that one the actual template itself is a
  674. 20:27frame and not a text button so we're
  675. 20:29gonna have to accommodate that and then
  676. 20:31additionally for the prices the template
  677. 20:33doesn't have a price text label actually
  678. 20:35has a prices frame with more frames
  679. 20:36inside of it so where we set the price
  680. 20:38for all of our templates so far we
  681. 20:39actually need to do something similar to
  682. 20:41what we do up here so we're going to say
  683. 20:42local price equals clone
  684. 20:45find first child price and then if we do
  685. 20:48find the price then what we'll do is
  686. 20:50what we've been doing this entire time
  687. 20:52so we'll do that otherwise we then know
  688. 20:54it's a booster template so we need to do
  689. 20:56something to specific for this template
  690. 20:58so we'll create another variable called
  691. 21:00prices and we're going to set that to
  692. 21:02clone.prices
  693. 21:03and the reason for that is because
  694. 21:04inside of this template we have the
  695. 21:06frame which is named the prices that
  696. 21:07holds all three of these other frames
  697. 21:10then we'll create three more variables
  698. 21:11so we're going to say price 10 equals
  699. 21:13prices dot and you can't do dot 10
  700. 21:16because that's invalid syntax what we
  701. 21:18need to do is we need to surround it in
  702. 21:20brackets and then we say 10 and then we
  703. 21:22could say dot buy and the reason we're
  704. 21:24doing that is because we're getting this
  705. 21:25frame right here and then we're getting
  706. 21:27the buy text button right here and then
  707. 21:28we want to create this same variable for
  708. 21:30the two other prices as well so price 30
  709. 21:33and price 60 and then we just need to
  710. 21:34change what we're indexing so price 30
  711. 21:37and price 60 and then we'll there we go
  712. 21:38now that we have all those what we then
  713. 21:40want to do is we want to say price 10
  714. 21:42dot price because the price label is
  715. 21:44inside of this buy button and then we'll
  716. 21:46set the text of the price text label
  717. 21:48inside of the button to info dot price
  718. 21:51one so now that we did that for 10 we've
  719. 21:53got to do that for 30 and 60 as well so
  720. 21:55we'll set price 30 to 2 and price 60 to
  721. 21:58price three and finally we need to
  722. 22:00handle the clicking of the buy button so
  723. 22:02what we're gonna do is we're gonna say
  724. 22:03price price ten dot mouse button one
  725. 22:07click connect create a new function and
  726. 22:09then for right now we'll just print true
  727. 22:11and then we'll duplicate this two times
  728. 22:13and then we'll do that for the remaining
  729. 22:15buttons so price 30 and price 60 and now
  730. 22:17we have all those buttons set up and now
  731. 22:19the final thing that we need to do for
  732. 22:20the mouse button click right here the
  733. 22:22boost template is a frame so it doesn't
  734. 22:24have a mouse bond one click event so
  735. 22:26what we need to do is we need to say if
  736. 22:28clone is a text button so if it's a text
  737. 22:31button then we will connect the mouse
  738. 22:33button one click event to the clone
  739. 22:35exactly like that then what we should do
  740. 22:36is make sure that the template is not
  741. 22:38visible and we need to do one more thing
  742. 22:40and that is create the for loop for them
  743. 22:42so we'll just copy the pets right here
  744. 22:44and we're going to say boosts and we
  745. 22:46also need to get the variables for them
  746. 22:47as well so boost container boost
  747. 22:50container boost template and we got to
  748. 22:51feed through the boost template and the
  749. 22:54boost container so then we'll start the
  750. 22:55game up open up the boost container and
  751. 22:57now we see this looks as it should so we
  752. 22:59have times five lux with all the
  753. 23:00different times if we click on the
  754. 23:02buttons we can see that they all do
  755. 23:03print out true then we have the
  756. 23:05timeshifty food once again we can click
  757. 23:07the buns and see if they print out and
  758. 23:08then we also have the times five coins
  759. 23:10as well and then for the coins we also
  760. 23:12have those as well we can click on those
  761. 23:13for the pets these all work as well and
  762. 23:15then for the passes they work too the
  763. 23:17final thing that we need to do is create
  764. 23:18the actual game passes and developer
  765. 23:20products before we create those we
  766. 23:22should differentiate between the two so
  767. 23:24that you guys know exactly which one you
  768. 23:25want to create game passes are meant to
  769. 23:27be are meant to be purchased one single
  770. 23:30time whereas developer products are
  771. 23:31meant to be purchased as many times as
  772. 23:33you want so for instance in the passes
  773. 23:35category we have the infinite food we
  774. 23:37most likely want this to be a game pass
  775. 23:39because we want the player to only be
  776. 23:40able to purchase this one time and will
  777. 23:42make it a permanent effect over the
  778. 23:44course of while they play but for
  779. 23:45packages like the coins maybe even the
  780. 23:47pets and the boosts we want those to be
  781. 23:49developer products because we want
  782. 23:50players to be able to repurchase them as
  783. 23:52many times as they want now for game
  784. 23:53passes you're unable to access those or
  785. 23:55create those in studio so you have to go
  786. 23:57to the roblox website make sure you're
  787. 23:59signed into the same account that you
  788. 24:00are in studio and you're creating the
  789. 24:02game on then you're going to want to
  790. 24:03click on create this will take you to a
  791. 24:04webpage which shows all the experiences
  792. 24:06that you've created on this page find
  793. 24:08the experience that you want to create
  794. 24:09the game passes for and then click the
  795. 24:11little settings icon this will create a
  796. 24:12drop down menu and you're going to want
  797. 24:14to click on create pass now on this page
  798. 24:16we are able to finally create our game
  799. 24:18pass so you can upload any image you
  800. 24:19want to display as your pass icon i'm
  801. 24:21just going to use the thumbnails for my
  802. 24:23past videos for hours then for the past
  803. 24:25name that will basically be the name or
  804. 24:26the title of your game pass we'll create
  805. 24:28the pass for two times food as i already
  806. 24:30created one for infinite food then for
  807. 24:32the description you can obviously set
  808. 24:34this to whatever you want to earn two
  809. 24:36times food while playing or you don't
  810. 24:38even have to add a description it's
  811. 24:39whatever you want to do then click on
  812. 24:41preview and if everything looks good
  813. 24:42click verify upload and it should create
  814. 24:44the game pass for you then when you see
  815. 24:46the passes click on the settings icon
  816. 24:48next to the newest one and then click
  817. 24:49configure and you'll be taken to this
  818. 24:51page right here you're going to want to
  819. 24:52go to sales and you're going to want to
  820. 24:53set this item for sale so players can
  821. 24:56actually buy it then you're going to
  822. 24:57want to set the price of the pass and
  823. 24:58for this pass it's going to be 549 and
  824. 25:01roadblocks tells us how much we'll earn
  825. 25:02from this so we're going to get 384
  826. 25:04robux every single time somebody buys
  827. 25:06this product now that this pass has been
  828. 25:08all set up we want to grab the id of the
  829. 25:10game pass from our address bar so we can
  830. 25:12see the id of this is six zero five five
  831. 25:14five six zero five and we're gonna need
  832. 25:16that for later now we'll create a
  833. 25:17developer product so inside a studio
  834. 25:19click the home tab and then click on
  835. 25:21game settings now when you open this you
  836. 25:22wanna go to the monetization tab and
  837. 25:24then here you can create badges but if
  838. 25:26you scroll down a little bit further you
  839. 25:27can also create developer products as we
  840. 25:29see i've already created a couple but
  841. 25:31let's go ahead and click on the create
  842. 25:32button now when we create one it'll just
  843. 25:34add it to this list right here let's go
  844. 25:35ahead click on the three dots click on
  845. 25:37edit and now give it a name and the
  846. 25:38price so for this we are going to say
  847. 25:40plus 276.4k
  848. 25:43coins and the price we're gonna set this
  849. 25:45to 79. and then we'll click save and if
  850. 25:47we open up the settings again go to
  851. 25:49monetization we can see we now have the
  852. 25:51developer product which turns out i
  853. 25:53already made this one already but that's
  854. 25:54fine this is just to show you guys how
  855. 25:55to create them and once again the
  856. 25:57important part here is the product id we
  857. 25:59are going to need that to easily copy
  858. 26:01this you just click on the three dots
  859. 26:02and then it gives you an option to copy
  860. 26:04the id to clipboard so then we have the
  861. 26:05id which is exactly what we need so now
  862. 26:07that we've created both the game pass
  863. 26:09and the developer product we can start
  864. 26:10adding that to our config and handling
  865. 26:12it in the shop so let's head over to the
  866. 26:14gamepad shop config and now we want to
  867. 26:16add new entries to all of the different
  868. 26:18items so for every single game pass item
  869. 26:20we want to create a new field called
  870. 26:22pass and the value of that is going to
  871. 26:24be the id of the game pass now for
  872. 26:26infinite food we didn't create that one
  873. 26:28this time but we did create the two
  874. 26:30times food so we're going to say pass
  875. 26:31equals and this is the game pass id that
  876. 26:33we created on the roblox website and
  877. 26:35then for all the developer products we
  878. 26:37want to add a field to them called
  879. 26:39product and we're going to set that to
  880. 26:40the id and remember we can go to
  881. 26:42monetization and we can and we can copy
  882. 26:44the id directly from here so let's go
  883. 26:46ahead take that id paste it into here
  884. 26:48and now we have an example of both a
  885. 26:49game pass and a developer product with
  886. 26:52the id so we can use these to prompt the
  887. 26:54player to purchase them so let's go back
  888. 26:55into the handler and start creating ways
  889. 26:57to prompt the player to purchase a
  890. 26:58specific item that they click on at the
  891. 27:00top of the script we want to initialize
  892. 27:02a new service and this is actually going
  893. 27:03to be the marketplace service and we're
  894. 27:06going to use the marketplace service to
  895. 27:07handle prompting the player to purchase
  896. 27:09the items so we want to scroll down to
  897. 27:10where we check if the clone is a text
  898. 27:12button then inside of here we want to
  899. 27:14check if it is a game pass or not so
  900. 27:16we're going to say if info.pass meaning
  901. 27:18that this has a pass field then what
  902. 27:20we're going to do is we're going to
  903. 27:22create a new variable called has pass
  904. 27:24and we're going to set this to true if
  905. 27:25the player already owns this game pass
  906. 27:27then we're going to say local success
  907. 27:30comma message equals p call and we're
  908. 27:32going to use a p call here and then
  909. 27:33we're gonna create an anonymous function
  910. 27:35inside of there and then we'll set has
  911. 27:36pass to marketplace service user owns
  912. 27:39game pass async then we need to pass the
  913. 27:42player's user id and the game pass id
  914. 27:44through to this method so we're gonna
  915. 27:46use the player service and then we'll
  916. 27:47just create a variable called local
  917. 27:49player equals players.local player and
  918. 27:51now we have the actual player so back
  919. 27:53down to the method we're going to say
  920. 27:55player.userid and pass through their id
  921. 27:57and then we're going to pass through the
  922. 27:59actual game pass id so we're going to
  923. 28:00say info.pat now the reason that we need
  924. 28:02to wrap this in a p call is because it's
  925. 28:04an async function and most of the times
  926. 28:06when you use async functions or
  927. 28:08functions that pull data from web pages
  928. 28:10or databases you usually have to wrap
  929. 28:11them in a p call because they can fail
  930. 28:13now after the p call we're gonna say if
  931. 28:15has passed so if this value has been set
  932. 28:18or it is equal to true then we can just
  933. 28:20print purchased for now because the
  934. 28:22player already owns the item otherwise
  935. 28:23we use the marketplace service to prompt
  936. 28:26purchase and then we need to pass
  937. 28:27through the player not the user id the
  938. 28:30actual player and then the info.pass so
  939. 28:32the pass id so that covers game passes
  940. 28:35but now we need to add developer
  941. 28:36products so inside the same if statement
  942. 28:38if info.pass then we want to add an else
  943. 28:41statement to this and all we're going to
  944. 28:42say is marketplace prompt product
  945. 28:44purchase and that refers to the
  946. 28:46developer products now i actually messed
  947. 28:47this up right here it's not prompt
  948. 28:49purchase it's actually prompt game pass
  949. 28:52purchase specifically so make sure you
  950. 28:53change that method if you use the other
  951. 28:55one so now with the prompt product
  952. 28:56purchase what we want to pass through
  953. 28:57here is once again the player and then
  954. 28:59we also need to pass through the product
  955. 29:01id so we're just going to say
  956. 29:03info.product because remember for the
  957. 29:05config if it is a product they have a
  958. 29:07product property so there we go we can
  959. 29:09also remove that print statement from
  960. 29:10there and we also need to add this for
  961. 29:11the boosters because the boosters are
  962. 29:13handled a little bit differently than
  963. 29:14the other items these are very simple to
  964. 29:16handle though all we need to do is we're
  965. 29:17just going to use the prompt product
  966. 29:19purchase so we'll replace the print
  967. 29:20statement right here in all of these and
  968. 29:22then we just need to do something in the
  969. 29:24config so the way that we're gonna have
  970. 29:25the config set up for these is for boost
  971. 29:27we're gonna say product one and that'll
  972. 29:29be set to the ten minute booster then
  973. 29:31product two is gonna be set to the
  974. 29:33second tier booster and then product
  975. 29:34three will be set to the third booster
  976. 29:36product id it's the exact same way that
  977. 29:38we did the price and we're just doing
  978. 29:40the same thing with different properties
  979. 29:41this time going back inside of the
  980. 29:42handler we just have to change this a
  981. 29:44little bit so we're going to say
  982. 29:45info.product1 info.product2 and
  983. 29:47info.product3 for the price 60 price 30
  984. 29:50and price 10. and now it's all good now
  985. 29:51we can go ahead start up our game test
  986. 29:53this out and see if it works now just
  987. 29:54remember when testing the only products
  988. 29:56that should actually work in this video
  989. 29:58is the two times food and the first coin
  990. 30:00package because those are the only ones
  991. 30:02that i just set up to showcase how to do
  992. 30:04it so let's click on two times food and
  993. 30:05we can see purchase is printed because
  994. 30:07if you're the owner of the game it acts
  995. 30:10as if you already have purchased the
  996. 30:11product but if we go to coins and then
  997. 30:13click on the first product it will pop
  998. 30:15up with a prompt for us to purchase this
  999. 30:17item because you're able to rebuy
  1000. 30:19developer products as many times as you
  1001. 30:20want additionally while you're in studio
  1002. 30:22if you do purchase anything it doesn't
  1003. 30:24subtract the robux from your account
  1004. 30:26because it's all testing inside a studio
  1005. 30:28and in the next episode we'll actually
  1006. 30:29use that testing so that we can create
  1007. 30:31the back end to our product system so
  1008. 30:32that's going to be it for this video in
  1009. 30:34the next episode we will create the
  1010. 30:35entire back end and go over all that
  1011. 30:37stuff for how to manage and give the
  1012. 30:38player the rewards on the server side
  1013. 30:40when they do purchase a product or a
  1014. 30:41game pass as always if this video did
  1015. 30:43help you guys out or you guys did enjoy
  1016. 30:44it make sure you smash the like button
  1017. 30:45also subscribe button and turn this post
  1018. 30:47notifications on if you want to get
  1019. 30:48notified when upload more roblox well
  1020. 30:49make content of course i do have a
  1021. 30:51patreon if you guys like to swarm me and
  1022. 30:52gain access to all the scripts and the
  1023. 30:53game file i made during this episode
  1024. 30:55there's a link down below description
  1025. 30:56and you guys can go and check that out
  1026. 30:57with that being said i'll see you guys
  1027. 30:58in the next episode

About this transcript

This page contains the full transcript of Scripting the Gamepass Shop Gui! Roblox Studio Simulator Guide Episode 22 by MonzterDEV, generated from the public captions YouTube serves with the video. The transcript has 7,776 words across 1,027 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.