YouTube2Text

Creating the Stats & Rewards Modules! Roblox Studio Simulator Guide Episode 12 — Transcript

by MonzterDEV · 5,637 words · 764 segments · language en · Watch on YouTube

Full transcript

  1. 0:00what's going on ladies and gentlemen
  2. 0:00welcome back to the simulator Series in
  3. 0:02today's episode we are going to be
  4. 0:03creating the stats and rewards module
  5. 0:05Handler for our simulator as always if
  6. 0:07you guys do enjoy the video or does help
  7. 0:09you out make sure you smash the like
  8. 0:10button also hit the Subscribe button and
  9. 0:11turn those post notifications on if you
  10. 0:13want to get notified when I upload more
  11. 0:14Roblox velic content additionally I do
  12. 0:16have a patreon if you guys like to
  13. 0:17support me and gain access to all the
  14. 0:19scripts and the game file that I make
  15. 0:20during this episode there's a link Down
  16. 0:21Below in the description you guys go
  17. 0:23check that out with that being said
  18. 0:24let's get into it so you're probably
  19. 0:26thinking why do we want or why do we
  20. 0:27need to make these modules let's first
  21. 0:29go over the rewards module there's
  22. 0:31countless methods that a player can earn
  23. 0:33rewards in most of the games if we think
  24. 0:34about it they have the main objective
  25. 0:36which in this game it's clicking every
  26. 0:37time you click you will get rewarded
  27. 0:39with a specific currency usually you
  28. 0:41also get rewards for daily logins
  29. 0:43completing quests achievements or jobs
  30. 0:46you can also usually purchase the main
  31. 0:47currency and then also entering in codes
  32. 0:49from Twitter or groups and things like
  33. 0:51that considering how many ways we can
  34. 0:53reward a player we should create a few
  35. 0:55specific functions which we'll use
  36. 0:56anytime we want to reward the player
  37. 0:58we'll simply provide the function the
  38. 0:59player and the amount to be rewarded
  39. 1:01while the function will handle all the
  40. 1:02other details like multipliers stats and
  41. 1:04things like that now let's think about
  42. 1:06why we want to have a module for the
  43. 1:07stats there are also countless ways a
  44. 1:09player can have increased stats in most
  45. 1:11games such as their level the equipped
  46. 1:13item that they have the pets they have
  47. 1:15equipped a friends bonus boosters or
  48. 1:17even purchases from the store as well so
  49. 1:20considering how many different systems
  50. 1:21can affect each stat of the player we
  51. 1:23should centralize this then whenever we
  52. 1:25need the value of the player specific
  53. 1:27stat we can call a function and simply
  54. 1:28provide the player the functional will
  55. 1:30do all of the other work of calculating
  56. 1:31the player stats and then we can use
  57. 1:32that stat however we want so let's
  58. 1:34actually create the modules within the
  59. 1:36server script service let's go ahead and
  60. 1:37create a new folder and we're going to
  61. 1:39rename this to utils if you're
  62. 1:41unfamiliar with what utilities are
  63. 1:43here's an example from one of my actual
  64. 1:45projects that I've been working on for a
  65. 1:46while now inside of this module script I
  66. 1:48have a function named format number and
  67. 1:50whenever I call this function alls I do
  68. 1:52is I pass through a number which can be
  69. 1:53either a number or a string and then
  70. 1:55this function will handle the backend
  71. 1:56work so it'll check if it's a string
  72. 1:58then it'll convert it to a number and
  73. 2:00then it'll call another function on it
  74. 2:01from a library and then it'll return
  75. 2:03that number so pretty much a utility
  76. 2:05module script contains different
  77. 2:06functions that you'll be using
  78. 2:08throughout your entire code base rather
  79. 2:10than having this format number function
  80. 2:12in five different scripts I put the
  81. 2:14function directly into one module script
  82. 2:15which I call from every single script
  83. 2:17that I want to use this function in and
  84. 2:19it keeps your code clean and allows us
  85. 2:21to centralize this one function so if
  86. 2:22there's ever a bug with it we can easily
  87. 2:24find it and fix it and stuff like that
  88. 2:26so with that being said hopefully I
  89. 2:27helped you guys understand utility
  90. 2:29scripts now we're going to go ahead and
  91. 2:30add in a brand new module script inside
  92. 2:32of our utils folder and we're going to
  93. 2:33rename this to Stats and then also for
  94. 2:36the module you don't have to change its
  95. 2:37name but I'm going to change it to Stats
  96. 2:39so there we go and then I'm going to
  97. 2:41duplicate this script and we're going to
  98. 2:42rename this to rewards and then we're
  99. 2:44going to change stats to rewards and
  100. 2:46there we go let's first work on creating
  101. 2:48the stats module script let's think
  102. 2:49about all the stats that we currently
  103. 2:51have in our game we have the food stat
  104. 2:53which increases the amount of food that
  105. 2:54you gain every single time you click we
  106. 2:56have the max food which increases the
  107. 2:58total amount of food that you can hold
  108. 3:00we have the coin stat which increases
  109. 3:01the amount of money you get from selling
  110. 3:03food and then we also have a general
  111. 3:05multiplier which you obtain from ranks
  112. 3:07and that increases your damage HP food
  113. 3:09and speed multiplier So currently we
  114. 3:11have about four different stats and now
  115. 3:13let's talk about all the different
  116. 3:15systems or ways that those stats are
  117. 3:17individually affected so the food stat
  118. 3:18is affected by the items that the player
  119. 3:20has equipped the pets that they have
  120. 3:21equipped the ranks that they have
  121. 3:23equipped if they've purchased a specific
  122. 3:25item for Roo from the store and also the
  123. 3:28booster system as well the max food Bo
  124. 3:30stat is affected Again by the items that
  125. 3:31the player has equipped it and if
  126. 3:33they've purchased anything from the
  127. 3:34store as well the coin stat is affected
  128. 3:36by the pets that they have equipped if
  129. 3:37they purchased a specific thing from the
  130. 3:39store and the Boost system and then the
  131. 3:41multiplier system that we were talking
  132. 3:42about with ranks is affected only by the
  133. 3:44rank that the player has equipped now
  134. 3:46the reason I wanted to go over all this
  135. 3:48is because we want to map out every
  136. 3:49single stat that we want to make a
  137. 3:51function for and we also want to map out
  138. 3:53every single thing that actually affects
  139. 3:55these stats and the reason for that is
  140. 3:57because when we're making our functions
  141. 3:58we want to make sure that we didn't for
  142. 3:59about a system and we didn't forget
  143. 4:01about anything when calculating the
  144. 4:03stats themselves so since we now mapped
  145. 4:05out all of the stats and what they're
  146. 4:06affected by let's go ahead and create a
  147. 4:07function for one of the stats the first
  148. 4:09stat that we're going to start working
  149. 4:10on is the food stat so let's go ahead
  150. 4:12and create a function for that and the
  151. 4:14only argument that it's going to accept
  152. 4:15is a player now we're going to be
  153. 4:17working with the general config files
  154. 4:18that we've been using this entire time
  155. 4:20inside of the replicated storage so
  156. 4:21let's go ahead and get all of those
  157. 4:22config files considering how many times
  158. 4:24we've already gotten those files you
  159. 4:26could copy it directly from the player
  160. 4:27data script or many of the other scripts
  161. 4:28that we've already done the same thing
  162. 4:30on now above the food function we
  163. 4:32actually want to create a local function
  164. 4:33called get item stat and that's going to
  165. 4:36accept the name of the item and it'll
  166. 4:38also accept the type of the item that
  167. 4:39we're going to look for as well and both
  168. 4:41these are going to be strings now the
  169. 4:42reason that we're creating the get item
  170. 4:44stat function is because the food stat
  171. 4:45is affected by the item the player
  172. 4:47currently has equipped so is the max
  173. 4:49food stat and the multiplier as well
  174. 4:51because that's affected by ranks so what
  175. 4:53the get items that function is going to
  176. 4:54do is we're going to pass this function
  177. 4:56the item that the player currently has
  178. 4:57equipped as well as the type of the item
  179. 4:59that we're looking for and then we're
  180. 5:00going to Loop through one of the configs
  181. 5:02so let's say for instance the tool
  182. 5:03config we're going to pass through the
  183. 5:05tool that the player has equipped then
  184. 5:06we're going to pass through tools so
  185. 5:07that we can know that this is the config
  186. 5:09we want to Loop through we're going to
  187. 5:10Loop through that config and then we're
  188. 5:11going to look for the ID which would be
  189. 5:13the name that we're passing through here
  190. 5:14and then once we find that specific tool
  191. 5:16with the same ID we're then going to
  192. 5:18return the stat that the item offers so
  193. 5:20as usual I feel like we've done this
  194. 5:21plenty of times now we're going to
  195. 5:23create a new variable inside of here
  196. 5:24called list and we are going to say if
  197. 5:27type equals food then tool config else
  198. 5:30if type equals rank then rank config
  199. 5:34else DNA config and that's how we're
  200. 5:36going to get our list then we will Loop
  201. 5:38through there so for underscore because
  202. 5:40we're not going to use the index config
  203. 5:42line in I pairs list do and then we're
  204. 5:45going to say if config
  205. 5:48line. is the same as name then we want
  206. 5:51to return the config line. stat and
  207. 5:54that's how we're going to get the item
  208. 5:56stat so now back inside of the food
  209. 5:57function we want to create a new
  210. 5:58variable called total and this variable
  211. 6:00is going to be used to perform the math
  212. 6:02on all of the different things which
  213. 6:04actually affect the stat so at the end
  214. 6:05of the script we just want to return the
  215. 6:07total because total will be the sum of
  216. 6:08all the systems which actually affect
  217. 6:10this specific stat let's make another
  218. 6:12variable inside of the food function
  219. 6:13called item and we're going to set that
  220. 6:15to the get item stat and we're going to
  221. 6:17provide the player. inventory. equipped
  222. 6:21rank. value now if you're unsure as to
  223. 6:23why we're providing this we can start up
  224. 6:25our game and we can go into the players
  225. 6:27we'll look inside of my player so think
  226. 6:29of it this way player. inventory and
  227. 6:31then inside of the inventory we have the
  228. 6:33equipped DNA the equipped rank or the
  229. 6:35equipped tool and then the value would
  230. 6:37be french fry 3 for example so that's
  231. 6:39why we're using that directory we set
  232. 6:40this system up a couple of episodes back
  233. 6:42and that's how our data system is set up
  234. 6:44but of course if you have a different
  235. 6:45data system that how we've set up here
  236. 6:47you'll obviously have to alter this to
  237. 6:48fit your own system so actually we're
  238. 6:50not going to provide it the equipped
  239. 6:51rank we're going to provide it the
  240. 6:52equipped tool because we're trying to
  241. 6:54figure out how much the specific item
  242. 6:55that the player has equipped is
  243. 6:56affecting their food stat and then we
  244. 6:58also want to pass through food the type
  245. 7:00as well so why don't we quickly test out
  246. 7:02this function to see if it actually
  247. 7:03works let's go inside of the tool
  248. 7:05manager and then we'll require that
  249. 7:07module script so server script service
  250. 7:09then local stats equals require serers
  251. 7:13script service. utils do stats so there
  252. 7:16we go we now have that and then let's
  253. 7:18say every single time we increase the
  254. 7:19player's food value let's just also call
  255. 7:21the stats. food as well and pass through
  256. 7:25the player and then let's just print
  257. 7:26this out as well so that we can see the
  258. 7:28actual amount that we get now that we're
  259. 7:30printing it out we also want to make
  260. 7:31sure that we don't forget to do the math
  261. 7:33So currently the only thing affecting
  262. 7:35the stat is the item right now so we of
  263. 7:37course need to add that to the total so
  264. 7:39we're going to say total plus equals
  265. 7:41item and you guys probably know this by
  266. 7:43now but plus equals pretty much just
  267. 7:44means total plus item it's just a
  268. 7:47simpler way of writing it so now we can
  269. 7:48go ahead and start the game pull out the
  270. 7:50tool click and we can now see three has
  271. 7:52been printed out and let's verify that
  272. 7:54that is correct so we currently have
  273. 7:56french fry 3 equipped and that should
  274. 7:58give us plus three food so that's
  275. 7:59working perfectly awesome so now that we
  276. 8:01have a general understanding of how
  277. 8:03we're finding the food stat value we
  278. 8:04should make a new function to return the
  279. 8:06multiplier for the specific stat so what
  280. 8:09I mean by that is when I displayed all
  281. 8:10the systems that affect the stats on
  282. 8:12screen they had either an addition or a
  283. 8:14multiplication symbol next to their name
  284. 8:16and the reason for that is because
  285. 8:17certain systems are going to be in
  286. 8:19additive value While others are
  287. 8:20multiplicative so if you think about the
  288. 8:21foods that the items and the pet system
  289. 8:24are additives to the food stat while the
  290. 8:26rank store and boost systems are
  291. 8:27actually multiplicative so what we want
  292. 8:29to do is we want to make a new function
  293. 8:31above the current food function and
  294. 8:32we're going to call that food multiplier
  295. 8:35and that's of course going to just
  296. 8:36accept the player again and we're pretty
  297. 8:38much going to set this up the same way
  298. 8:39so we're going to say total equals zero
  299. 8:41and then we are going to return the
  300. 8:43total so if we think back to what
  301. 8:44systems affect the food multiplier we
  302. 8:46have the rank system so we're going to
  303. 8:47say local rank get item stat we'll pass
  304. 8:50through the equipped rank this time so
  305. 8:52instead of tool equipped Rank and then
  306. 8:54we'll also pass through rank as well and
  307. 8:56then of course we want to do math with
  308. 8:58that so we're going to say total plus
  309. 9:00equals rank that'll add the rank to the
  310. 9:02multiplier and now we figured out the
  311. 9:03multiplier so what we can do to just
  312. 9:05verify that this is working as it should
  313. 9:07be let's go back inside of the tool
  314. 9:08manager and we can test this out so this
  315. 9:10time call the food multiplier function
  316. 9:12start it up and let's see what it prints
  317. 9:14out so we equip for french fry click and
  318. 9:16we can see one has been printed out and
  319. 9:18if you guys are confused by all the
  320. 9:19different numbers on line 17 that is the
  321. 9:21food multiplier and on line 16 that is
  322. 9:24just the food stat so that's good to
  323. 9:25know that that is working perfectly fine
  324. 9:27now one thing I want to make note of
  325. 9:28that could possibly be different if your
  326. 9:30system is different than ours is the
  327. 9:32multiplier should probably never
  328. 9:34actually be zero because of course if
  329. 9:36you guys multiply the food by the
  330. 9:38multiplier which is equal to zero then
  331. 9:40the food would also equal zero as well
  332. 9:43but considering how our rank system is
  333. 9:44set up even by default when the player
  334. 9:46first joins the game their multiplier
  335. 9:48will at least be one it will never be
  336. 9:50zero so if your system is different than
  337. 9:52ours and you might run into this
  338. 9:54complication of multiplying by zero what
  339. 9:56I would recommend doing is instead of
  340. 9:57returning total you would say if total
  341. 10:00is greater than zero then return total
  342. 10:03otherwise return one so at least then
  343. 10:05you're always returning something
  344. 10:06greater than one but of course I'm going
  345. 10:07to revert that change and we're going to
  346. 10:09go back to just returning total because
  347. 10:10of how our system works now considering
  348. 10:12we don't have any of the other systems
  349. 10:14implemented into our game which affect
  350. 10:16the food stat such as pets the store or
  351. 10:18boosters we obviously can't add any of
  352. 10:20those systems to incorporate for this
  353. 10:22but let me show you a small example of
  354. 10:24how we would also add those values into
  355. 10:26this as well so let's say for example
  356. 10:27pets we would create a variable called
  357. 10:29pet and we would probably set the value
  358. 10:30of that to a module script named pets
  359. 10:33and that module script will have a
  360. 10:34function called get stat and then we
  361. 10:36would probably pass through the stat
  362. 10:38that we want to get so food and then
  363. 10:40that would return a number of the food
  364. 10:42stat that all the pets have combined we
  365. 10:44would add the pet system to the total
  366. 10:46just like how we add the item system to
  367. 10:47the total as well and that's how we
  368. 10:49would calculate the stat but of course
  369. 10:50since we don't have the pet stat yet we
  370. 10:52obviously can't do that this is just an
  371. 10:54example of how that would work and then
  372. 10:55of course inside of the food multiplier
  373. 10:57if we wanted to add boost to this we
  374. 10:58would just say boosts equals and then
  375. 11:01there would probably be a module script
  376. 11:02for handling the Boost system get stat
  377. 11:04and then we provide it the food stat and
  378. 11:07then we of course we would add the Boost
  379. 11:08to the total as well similarly to how we
  380. 11:10did pets down below so those are just
  381. 11:12examples of how you would incorporate
  382. 11:13more systems into modifying the stats
  383. 11:15value and of course we'll be adding
  384. 11:17those later in the series Once We
  385. 11:18actually create those systems as well
  386. 11:19now that we have the food multiplier and
  387. 11:21the food stat calculation done we can
  388. 11:23move on to another stat so let's create
  389. 11:25a new function called stats. Max food
  390. 11:28and of course it's going to return the
  391. 11:29Max food stat so what is the max food
  392. 11:31stat affected by well once again it is
  393. 11:33affected by the item that a player
  394. 11:34currently has equipped and that would be
  395. 11:36the DNA so instead of looking at the
  396. 11:38tool we're going to look at the equi DNA
  397. 11:40and we're going to pass through DNA as
  398. 11:41the type as well and that'll get us the
  399. 11:43player's Max food stat now Max food is
  400. 11:45also affected by an item that the player
  401. 11:47can purchase from the store for Roo if
  402. 11:49the player purchases the item from the
  403. 11:51store for Roo they actually get
  404. 11:53unlimited Max food so we'll of course
  405. 11:55incorporate that system into this later
  406. 11:57when we do make the store system now I'm
  407. 11:58going to go ahead copy and paste this
  408. 12:00again and now we'll create the coin stat
  409. 12:02now the coin stat is affected by the
  410. 12:04pets the player has equipped an item
  411. 12:05they can purchase from the store and the
  412. 12:07Boost system now we can remove the item
  413. 12:09variable from here and also delete the
  414. 12:11equation right there and now since we
  415. 12:12don't have any of the systems which by
  416. 12:14default will give the player one coin
  417. 12:16stat we want to set the total by default
  418. 12:18to one and now usually when we use the
  419. 12:20coin stat we are going to be multiplying
  420. 12:21a specific number by the coin stat and
  421. 12:24of course if we multiply that number by
  422. 12:26zero then that's going to give the
  423. 12:27player zero coins and we don't want that
  424. 12:29to happen additionally we can make
  425. 12:31another stat let's go ahead and copy and
  426. 12:33paste the coin stat and we're going to
  427. 12:34name that coin multiplier and the total
  428. 12:36is going to be set to zero and then we
  429. 12:38are going to want to get the rank so we
  430. 12:40can copy the rank from the food
  431. 12:41multiplier and put the rank directly
  432. 12:43into the coin multiplier we can add the
  433. 12:45rank to the total and there we go we now
  434. 12:47have the coin multiplier now if you're
  435. 12:48confused as to why I'm using the rank in
  436. 12:50the coin multiplier when I didn't
  437. 12:52mention it before I just went back and
  438. 12:53tested on eating simulator and it seemed
  439. 12:55like they have a very odd equation which
  440. 12:57doesn't exactly make sense I couldn't
  441. 12:59find a definitive answer about it but it
  442. 13:01seems like their coing multiplier is
  443. 13:03affected by the player's rank of course
  444. 13:05this series is to teach you guys how to
  445. 13:06make your own simulator so it's not like
  446. 13:08you'll have to worry about silly things
  447. 13:09that eating simulator does but I'm just
  448. 13:11trying to clarify why I'm now adding
  449. 13:12rank to this when I previously didn't
  450. 13:14mention it so since the coin multiplier
  451. 13:16is affected by the rank we now have the
  452. 13:17coin multiplier stat and the coin stat
  453. 13:19by default is just one and that's all
  454. 13:21good to go and now the last stat that
  455. 13:23we're going to add which we have
  456. 13:24currently is going to be called the
  457. 13:25general stat and of course that's going
  458. 13:27to accept the player now we might name
  459. 13:29this to something better in the future
  460. 13:30but General is the only decent name that
  461. 13:32I could think of so far the stat that
  462. 13:34I'm referring to with General is the
  463. 13:36stat which is affected by the rank
  464. 13:37system I guess realistically instead of
  465. 13:39calling that the general stat we could
  466. 13:40even just call it the rank stat that
  467. 13:42might be a little bit better and this
  468. 13:43stat is relatively simple we just have
  469. 13:45to return the Direct Value that we're
  470. 13:46getting from the get item function when
  471. 13:48we pass through the rank information so
  472. 13:50what this stat is going to affect is
  473. 13:52things like the player Health the player
  474. 13:54speed the player's damage the food
  475. 13:55multiplier the coin multiplier which
  476. 13:57instead of doing the get item stat we
  477. 14:00could actually now just call the stat
  478. 14:02rank player and that will also get us
  479. 14:03the same value and I guess that would be
  480. 14:05good so we're not repeating code on
  481. 14:07necessarily so with all that being said
  482. 14:08we're pretty much finished all the stats
  483. 14:10module at least for now until we add
  484. 14:11more of the other systems like the pet
  485. 14:13system the Roo storage system and other
  486. 14:15things like that so we can now move on
  487. 14:16to creating the reward module so before
  488. 14:18we create the reward module let's think
  489. 14:20of a few common rewards given in our
  490. 14:22simulator and what systems give them so
  491. 14:24for instance we have food as a reward
  492. 14:25and the system that gives this reward is
  493. 14:27by clicking it's the main system that we
  494. 14:28have in our game we then have the coins
  495. 14:30currency which is given from selling
  496. 14:31food daily logins and also the Robux
  497. 14:34store and then another reward that we
  498. 14:35have are pets and these can be obtain
  499. 14:37from hatching eggs trading with other
  500. 14:38players and then also the Roo store as
  501. 14:41well now you might also be thinking that
  502. 14:42we do have a shop GUI and those items
  503. 14:44from the shop GUI such as the food DNA
  504. 14:47and ranks would also be rewards that
  505. 14:49could fall into this system which is
  506. 14:50true but considering the items purchased
  507. 14:52from our shop are only obtained from the
  508. 14:54shop system besides one DNA item which
  509. 14:56is the infinite food and that's
  510. 14:58purchased for Rob bu it might actually
  511. 15:00be unnecessary to move all of that
  512. 15:01functionality into this specific module
  513. 15:04because the main point of a module is
  514. 15:05for reusability the advantage though of
  515. 15:08including the shop items in the reward
  516. 15:09module is that we're keeping all reward
  517. 15:11systems in one specific script for now
  518. 15:13though I'm going to choose to not
  519. 15:15include the shop items in a reward
  520. 15:16module but this could change in the
  521. 15:18future anyways with all that being said
  522. 15:19let's go ahead and actually create our
  523. 15:21food reward method inside of the rewards
  524. 15:23module let's go ahead and create a new
  525. 15:24function called rewards. food and now
  526. 15:27let's think food is rewarded each time a
  527. 15:29player clicks while holding a food item
  528. 15:31based off this our method should accept
  529. 15:32the player and the amount of food that
  530. 15:34we want to give to the player so our
  531. 15:35first argument is of course going to be
  532. 15:37the player which is a player and the
  533. 15:38second argument is going to be the
  534. 15:40amount of food that we want to give to
  535. 15:41the player and that's going to be a
  536. 15:43number now we usually have to really
  537. 15:44plan out how we're actually going to
  538. 15:46give the player food directly but we've
  539. 15:48already done this inside of our tool
  540. 15:50manager which is inside of the server
  541. 15:52script service so right here inside of
  542. 15:53the function which is connected to the
  543. 15:54tool activated event we adjust the
  544. 15:56player's food value right here so player
  545. 15:58leader stat food. value and then we set
  546. 16:00that to itself plus the tool stat and
  547. 16:03this actually doesn't take an account
  548. 16:04for the multiplier which we just
  549. 16:05calculated inside of our stats but
  550. 16:07really the important information that we
  551. 16:08want is directly from right here so
  552. 16:10we're going to go ahead and copy this
  553. 16:11player. leer stats. food. value and
  554. 16:13we'll go ahead and paste it inside of
  555. 16:15our food method and then we want to set
  556. 16:17that to plus equals amount so we add the
  557. 16:19amount to the current food value now we
  558. 16:21could just simply call this method right
  559. 16:23now and it would work if for instance we
  560. 16:25called this method from the tool manager
  561. 16:26rather than giving the player the food
  562. 16:28this way it would actually reward the
  563. 16:30player food but we're also completely
  564. 16:32forgetting about the multiplier stat and
  565. 16:33remember inside of our stats module we
  566. 16:35already created the food multiplier
  567. 16:37method which will calculate the
  568. 16:38multiplier for us and we want to add
  569. 16:40that multiplier inside of this method
  570. 16:42right here so let's go ahead and
  571. 16:43initialize the stats module inside of
  572. 16:45here so we want to get the server script
  573. 16:47service and then of course we want to
  574. 16:49get the stats module which is inside of
  575. 16:51the serers script service. utils do
  576. 16:54stats and there we go so let's go ahead
  577. 16:55and create a variable inside of here
  578. 16:57called multiplier and then we're going
  579. 16:59to set that to stats. food multiplier
  580. 17:02and we'll pass through the player and
  581. 17:03now we can get the food multiplier and
  582. 17:05of course we want to use this multiplier
  583. 17:07rather than just adding the amount we
  584. 17:08want to multiply the amount by the
  585. 17:10multiplier and then add that to the
  586. 17:12player's current food so now this is a
  587. 17:13pretty perfect method but let's expand
  588. 17:15on it a little bit what if we didn't
  589. 17:16want to use the multiplier for example
  590. 17:18let's say that we have a daily reward
  591. 17:20which will give the player food but we
  592. 17:22want to only give them that specific
  593. 17:23amount of food and not have the amount
  594. 17:25affected by the multiplier so what we're
  595. 17:27going to do is we're going to actually
  596. 17:28accept another argument in this method
  597. 17:30that's going to be called Ed multiplier
  598. 17:32and it's actually going to be a bullying
  599. 17:33by default we're going to set the Ed
  600. 17:35multiplier to true so we're going to say
  601. 17:36use multiplier equals if use multiplier
  602. 17:39does not equal nil then use multiplier
  603. 17:42otherwise it's going to be set to True
  604. 17:44by default and now when we're setting
  605. 17:46the multiplier what we want to do is if
  606. 17:48used multiplier is true then we want to
  607. 17:50set that to the food multiplier
  608. 17:51otherwise we want to set it to one so it
  609. 17:53doesn't actually affect the amount and
  610. 17:55of course the way that we can do this is
  611. 17:56by saying if use multiplier equals true
  612. 17:59then stats. food multiplier else one so
  613. 18:02now if we do want to use the multiplier
  614. 18:04then we will use the multiplier
  615. 18:05otherwise the multiplier will be set to
  616. 18:06one and of course any amount Time 1 will
  617. 18:09equal one of course besides zero but
  618. 18:10that's besides the point let's now test
  619. 18:12this method out let's add a print
  620. 18:13statement inside of here and just to
  621. 18:15make sure that everything's working
  622. 18:16correctly we're going to accept the
  623. 18:17amount the multiplier and the amount
  624. 18:20times multiplier so that we can see the
  625. 18:22direct amount the direct multiplier and
  626. 18:23then the amount times multiplier which
  627. 18:25is going to the player and now we want
  628. 18:26to call this method inside of the tool
  629. 18:29manager which is already handling when
  630. 18:30the player clicks and then to reward the
  631. 18:32player some money now if we look inside
  632. 18:34of how we're currently rewarding the
  633. 18:35player money we're actually doing a lot
  634. 18:37of work that we've already covered
  635. 18:39inside of the stats module so what this
  636. 18:40means is we could actually literally
  637. 18:42delete all of this and now instead of
  638. 18:44using all of that what we can do is well
  639. 18:46first we want to add the rewards module
  640. 18:48into the script so let's go ahead and
  641. 18:50get the rewards module there we go and
  642. 18:52now what we're going to say is rewards.
  643. 18:54food pass through the player and then
  644. 18:56for the amount we're going to say stats
  645. 18:58do food and of course pass through the
  646. 19:00plier and now we could pass through true
  647. 19:02although we don't have to because
  648. 19:03remember by default use multiplier is
  649. 19:05true so realistically all we have to do
  650. 19:07is call this method pass through the
  651. 19:08player and then pass through the amount
  652. 19:10of food that we want to give to that
  653. 19:11player and to get the food amount we
  654. 19:13just have to call the stats method right
  655. 19:14here and now we're all good to go so
  656. 19:16let's go ahead and save that and start
  657. 19:17up our game and see if that works
  658. 19:18correctly so hold out our tool go ahead
  659. 19:20and click and we can see in the consoles
  660. 19:22printed out three which is the
  661. 19:23multiplier and nine which is the total
  662. 19:25amount given to the player and if we
  663. 19:26look at our food we can see I currently
  664. 19:28have 4, ,31 food and then if we click we
  665. 19:31now have
  666. 19:324,140 so just checking everything's
  667. 19:34working correctly and it does let's also
  668. 19:36go inside of our shop rather than having
  669. 19:38french fry 3 equipped let's equip number
  670. 19:39one now let's go ahead and click while
  671. 19:41holding french fry 1 and we can see the
  672. 19:43amount given is one the multiplier is
  673. 19:45three so the amount times multiplier is
  674. 19:47also three as well and that means we're
  675. 19:48getting three coins and the reason our
  676. 19:50multiplier is three is because we have
  677. 19:52the third rank equipped right now if we
  678. 19:54wanted to we could equip the first Rank
  679. 19:55and now we should see 11 one and that's
  680. 19:57exactly what we see so so this is all
  681. 19:59working perfectly stats are being
  682. 20:00calculated exactly how they should be
  683. 20:02and the food is given to the player with
  684. 20:04the exact total that it should be as
  685. 20:05well so going back inside of a rewards
  686. 20:07module we can go ahead and delete this
  687. 20:09print statement and this method is
  688. 20:10pretty perfect in the future we might
  689. 20:12expand on it and we could even create a
  690. 20:13new remote event which we use to notify
  691. 20:16the player every single time that
  692. 20:17they've been given food and then we can
  693. 20:19make a screen GUI pop up which will be
  694. 20:21used as a notification to display to the
  695. 20:23player that they have earned food but
  696. 20:24for right now this is perfectly fine and
  697. 20:26this could be easily expanded in the
  698. 20:28future we now want to do is we're going
  699. 20:29to go ahead and copy this and now create
  700. 20:31a method for rewarding coins to the
  701. 20:33player so we're going to go ahead copy
  702. 20:34that paste it and rename this method
  703. 20:36from food to coins although currently we
  704. 20:38actually don't have a system set up for
  705. 20:40selling food to earn coins although that
  706. 20:42will come in future episodes
  707. 20:44realistically the only changes that we
  708. 20:45need to make to this method currently is
  709. 20:47change the multiplier or where the
  710. 20:49multiplier comes from so rather than the
  711. 20:50food multiplier we're of course going to
  712. 20:51use the coin multiplier and then change
  713. 20:53the directory where the rewards go
  714. 20:54through so rather than Food they'll be
  715. 20:56going to coins and now similar to
  716. 20:58calling the food method we could also
  717. 20:59call the coins method anywhere we want
  718. 21:00to reward the player coins rename this
  719. 21:02two coins and of course just pass
  720. 21:04through the player and then rather than
  721. 21:05passing through the food stat we would
  722. 21:07pass through the coin stat and now we
  723. 21:08would be rewarding the player the
  724. 21:10specific amount of coins that they
  725. 21:11should be receiving although of course
  726. 21:12since the player shouldn't earn coins
  727. 21:14along with earning food I'm going to
  728. 21:15remove this I was just showing you guys
  729. 21:17how you could call that method now
  730. 21:18originally when we first discussed the
  731. 21:19rewards module I did mention that pets
  732. 21:22are a system that could fall into this
  733. 21:23module the thing is though is that it's
  734. 21:25really hard for me to even show you guys
  735. 21:26an example of what the pet method look
  736. 21:28like just because it's drastically
  737. 21:30different from food and coins which is a
  738. 21:32currency without the pet system actually
  739. 21:34being set up right now it would be
  740. 21:35really hard for me to make a
  741. 21:37demonstration understandable for you
  742. 21:38guys as to why we need the specific
  743. 21:40things that we need so that's why I'm
  744. 21:41not going to even try to get into
  745. 21:43showing you guys what the pet reward
  746. 21:45method would look like we'll do that in
  747. 21:46the future when we create the actual pet
  748. 21:48system but with that being said ladies
  749. 21:49and gentlemen that's going to be it for
  750. 21:50this episode hopefully you guys did
  751. 21:51enjoy as always if you guys did make
  752. 21:53sure you smash the like button also hit
  753. 21:54the Subscribe button and turn those post
  754. 21:55notifications on if you want to get
  755. 21:57notified when I upload more Roblox
  756. 21:58development content additionally I do
  757. 22:00have a patreon if you guys like to
  758. 22:01support me and gain access to all the
  759. 22:02scripts and the game file that I made
  760. 22:03during this episode there's a link Down
  761. 22:05Below in the description you guys go
  762. 22:06check it out with that being said I hope
  763. 22:07that you guys have a great day and I'll
  764. 22:08see you guys in the next episode

About this transcript

This page contains the full transcript of Creating the Stats & Rewards Modules! Roblox Studio Simulator Guide Episode 12 by MonzterDEV, generated from the public captions YouTube serves with the video. The transcript has 5,637 words across 764 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.