YouTube2Text

[NEW]How to make A Pet Simulator X Game on Roblox - Part 2 — Transcript

by polarisprog · 4,768 words · 693 segments · language en · Watch on YouTube

Full transcript

  1. 0:00hi everyone and welcome back to the
  2. 0:02updated pet X St game series in this
  3. 0:05video I'm going to be showing you how to
  4. 0:06make this simple egg hatching system as
  5. 0:09well as shown you how to make this door
  6. 0:12opening
  7. 0:14system also if you guys want to support
  8. 0:16me and want to have access to all of my
  9. 0:18project files including the one you're
  10. 0:20watching right now they will all be
  11. 0:22available on my patreon in$ tier the
  12. 0:25link will be in the description with
  13. 0:26that being said let's start all right so
  14. 0:30so the first thing we're going to do is
  15. 0:31work on the ounting system now we're
  16. 0:33going to need a uh egg an egg mesh for
  17. 0:36this so I have this mesh part right here
  18. 0:38that's an egg and I renamed it to basic
  19. 0:42egg and what I'm going to do is inside
  20. 0:44of that basic egg I'm going to add a
  21. 0:45proximity prompt now I'm going to set
  22. 0:47the action text to open and the requires
  23. 0:51line of site property to false and then
  24. 0:54the uh hold duration to
  25. 0:560.4 and then I'm going to add a modu
  26. 0:59script do this which I'm which I'm going
  27. 1:01to rename to
  28. 1:03data and inside of that this data module
  29. 1:05I'm going to have a return and we're
  30. 1:08going to return the egg price so we're
  31. 1:10going to store the egg price which will
  32. 1:11be 10 and then the egg
  33. 1:13currency which will be maybe coins you
  34. 1:16can have it as Gems or any currency you
  35. 1:19have and then we're going to need the
  36. 1:21egg pets so egg
  37. 1:24pets curly brackets again and the first
  38. 1:27betet is going to be a uh okay so a
  39. 1:31table again and it's going to be called
  40. 1:33so pet name will be
  41. 1:35cat and the chance of getting one will
  42. 1:39be 100% so 100 and I forgot to add the
  43. 1:44comma right here and then the Rarity
  44. 1:46which will be so Rarity uh
  45. 1:51common and if you want to add the second
  46. 1:53pet just copy this baste it here and
  47. 1:55change this to two instead of one and
  48. 1:58this time also make sure to have a comma
  49. 2:00right here and it will be maybe Fox and
  50. 2:03the Rarity will be
  51. 2:0550% now make sure that both of these
  52. 2:09percentages add up to 100% so now this
  53. 2:12is not right so I'm going to have this
  54. 2:13one as maybe 70% and the other one is
  55. 2:1830% just make sure that that they add up
  56. 2:21to 100 and maybe this can be
  57. 2:23uncommon but for now I'm only going to
  58. 2:25have the cat so just cat
  59. 2:30and what I'm going to do now is add a
  60. 2:33folder inside of the main folder _
  61. 2:35workspace and it's going to be called
  62. 2:37eggs and I'm going to have this basic
  63. 2:39egg mesh inside of this and what I'm
  64. 2:42going to do
  65. 2:44is go to starter
  66. 2:46player starter player scripts and I'm
  67. 2:49going to add a local script and it's
  68. 2:50going to be um egg
  69. 2:54client now in this module script we're
  70. 2:57gonna I mean in this script sorry we're
  71. 3:00going to script the uh X system on from
  72. 3:03the client so what I'm going to do is
  73. 3:05local run service we're going to start
  74. 3:07with some services so run service is
  75. 3:10equal to
  76. 3:11game uh game call a service run service
  77. 3:15and then we're going to get replicated
  78. 3:17storage replicated storage is equal to
  79. 3:20game call get service replicated storage
  80. 3:22then we need local players it's get
  81. 3:25service players then we need tween
  82. 3:28service local twn
  83. 3:30service this equal to game call get
  84. 3:33service TW
  85. 3:34service and then we're going to
  86. 3:37need
  87. 3:39um a reference to RX so
  88. 3:42local X is equal to workspace for child
  89. 3:46main folder workspace for child egg and
  90. 3:50then we're going to need the remotes
  91. 3:51loal remotes is equal to eggs or
  92. 3:54replicator storage call for child
  93. 3:56remotes and then we need the pets so
  94. 3:59loal pets is equal to replicate and
  95. 4:00storage with child pets and then we're
  96. 4:03going to need the player so local player
  97. 4:06is equal to players local
  98. 4:09player and local okay so now we need
  99. 4:11some UI so what I'm going to do is exit
  100. 4:16out of the script and inste of our
  101. 4:17started GUI I'm going to add a screen
  102. 4:19GUI and it's going to be called um egg
  103. 4:25system and inside of that I'm going to
  104. 4:28have a uh
  105. 4:30viewport frame and I'm going to position
  106. 4:33it right here put it right here and I'm
  107. 4:37going to change its size to one 0.1
  108. 4:41comma 0 comma 0.1 comma 0 and then I can
  109. 4:44resize it because now it's converted to
  110. 4:46scale so I can just make it a square
  111. 4:49make it bigger put it somewhere around
  112. 4:52here and inside of that viewport frame
  113. 4:55I'm going to have also I'm going to call
  114. 4:57this egg viewport
  115. 5:01and inside of that we're going to have a
  116. 5:03text label and I'm also going to change
  117. 5:05it size to one comma 0 comma 0.1 comma
  118. 5:100 and I'm going to make it a bit bigger
  119. 5:12and I'm going to drag it down here and
  120. 5:15I'm going to duplicate it and put the
  121. 5:16other one
  122. 5:17here and I'm going to select both of
  123. 5:20them of my text labels and I'm going to
  124. 5:21change the background transparency to
  125. 5:23one the
  126. 5:25text color to maybe White and the font
  127. 5:28to for do
  128. 5:30one for do one and then I'm going to
  129. 5:34change the uh okay so the text will be
  130. 5:39nothing and inside of both of them we're
  131. 5:42going to add a UI
  132. 5:46stroke so I'm just going to make
  133. 5:50it um okay where is
  134. 5:52it I'm going to give them a text so
  135. 5:55maybe common or cat
  136. 6:01and I'm going to make this a bit smaller
  137. 6:03and then I'm going to make sure that t
  138. 6:05scal is checked
  139. 6:06sorry and I think this looks good now
  140. 6:09I'm going to do the same thing for the
  141. 6:10other one so select the UI stroke place
  142. 6:13it into this make sure that Tex scale is
  143. 6:16checked and what we also need to do is
  144. 6:20so the first one will be a name label so
  145. 6:22I'm going to call it name label and the
  146. 6:24second one is going to be called Rarity
  147. 6:26label
  148. 6:29okay so now the background transparency
  149. 6:31of the of the viewport frame will be one
  150. 6:34and then I'm going to make sure that the
  151. 6:36enabled property is set to false on the
  152. 6:39X system and what I'm going to do now is
  153. 6:41go back to my X client script and what
  154. 6:44I'm going to do is get local egg view
  155. 6:47portal or egg system SS is equal to
  156. 6:51player call with for child player gy
  157. 6:54call for child egg
  158. 6:58system and and local egg viewport is
  159. 7:02equal to egg system assass con for child
  160. 7:05egg
  161. 7:07viewport okay so what I'm going to do
  162. 7:09now is have a function called hatch egg
  163. 7:11so hatch egg and it's going to take the
  164. 7:15egg
  165. 7:15name and then the chosen pet so chosen
  166. 7:20pet and what I'm going to do is have a
  167. 7:22for Loop right here and what's this for
  168. 7:25going to do is just okay so I'm going to
  169. 7:29Loop through
  170. 7:30the through um
  171. 7:33player call Wa for child player gy call
  172. 7:38and get children or player dot okay so
  173. 7:41I'm going to do player do player gy call
  174. 7:45and get children and we're going to
  175. 7:46check if it's screen gy then uh we're
  176. 7:48going to check if V is not equal to our
  177. 7:50EX system gy and then we're going to
  178. 7:52disable it and then I'm going to Loop
  179. 7:57through the egg view port
  180. 7:59and we're going to check if there is a
  181. 8:01camera inside of it or if it or if there
  182. 8:03is a base part or a model then we're
  183. 8:05going to destroy it and then we will
  184. 8:08make the size of the x view Port so X
  185. 8:11viewport do size will be using to. from
  186. 8:16from scale and 0 comma
  187. 8:200 and then local egg
  188. 8:23mesh is equal to
  189. 8:25egg egg going find first child um egg
  190. 8:30name col
  191. 8:33clone and then we're going to parent it
  192. 8:36so egg mesh parent is equal to uh egg
  193. 8:42viewport and then egg mesh
  194. 8:46cframe is equal to CF frame. new 0 comma
  195. 8:500 comma 0 I'm just going to add some
  196. 8:53spaces right
  197. 8:54here and then local camera we're going
  198. 8:57to create a camera is equal to instance.
  199. 8:59new
  200. 9:01camera and Camera parent is equal to egg
  201. 9:07viewport and
  202. 9:10Camera cframe equal to cframe do new CF
  203. 9:13frame. new 0 comma 0 comma 0 comma 4 and
  204. 9:19then uh viewport current camera current
  205. 9:24camera is equal to to um camera
  206. 9:30and then I'm going to create tween so
  207. 9:33tween service call create uh what am I
  208. 9:36doing call create and X viewport comma
  209. 9:41TW
  210. 9:42info new uh maybe 0.7 seconds
  211. 9:470.7 comma and we're going to change the
  212. 9:49size to to do new and what I'm going to
  213. 9:54do is get the size of my egg viewport so
  214. 9:58just type in the size and copy it and
  215. 10:00then you can paste it right here and
  216. 10:02just get rid of the curly
  217. 10:08brackets and then we're going to add a
  218. 10:10colum play at the end and then after
  219. 10:14we're going to wait for this to so task
  220. 10:17we going wait for this TW to finish 0.7
  221. 10:20so we're going to wait 0.7 seconds and
  222. 10:23what we're going to do is for I is equal
  223. 10:26to from 1 to 4
  224. 10:31and what I'm going to do is Twin service
  225. 10:34on Create and x view Port comma TW info.
  226. 10:39new
  227. 10:400.3 comma en. style. sign comma en. e in
  228. 10:45direction eing direction
  229. 10:49out comma and I'm going to change the
  230. 10:53rotation so just rotate the egg we're
  231. 10:55going to set the rotation to 20 and we
  232. 10:58going to play this TW and then we're
  233. 11:00going to wait 0.3
  234. 11:03seconds and we're going to copy this
  235. 11:05tween right here and we're going to
  236. 11:06paste it in here but this time it's
  237. 11:07going to be minus
  238. 11:0920 and we're going to add another task.
  239. 11:12we
  240. 11:130.3 and after that is done well we will
  241. 11:18create a new twin so twin
  242. 11:20service we are pretty much just going to
  243. 11:24do the same thing just copy one of these
  244. 11:26twins put it here and change the
  245. 11:28rotation to zero this time and then
  246. 11:30we're going to wait t. wait 0.3
  247. 11:34seconds and what I'm going to do is
  248. 11:39just okay so I'm going to change to copy
  249. 11:41this twen right here of the viewport
  250. 11:43size paste it right here and we're going
  251. 11:45to change the size to 0a 0 comma 0 comma
  252. 11:500 and then what I'm going to do is wait
  253. 11:540.3 0.3 seconds also we can simplify
  254. 11:58this by doing medum to from scale and
  255. 12:01just put in 0 comma 0 that should be a
  256. 12:05bit better and then I'm going to Loop
  257. 12:09through the EG view Port going get
  258. 12:11children and we're going to check if
  259. 12:13there is a camera or base part or model
  260. 12:15then we're going to destroy it and then
  261. 12:17we'll get a pet model so look pet model
  262. 12:20is equal to and pets going find first
  263. 12:23child chosen pet do pet
  264. 12:27name pet name name col
  265. 12:31clone and pet model pet model call pivot
  266. 12:362 d frame. new 0 comma 0 Comm
  267. 12:400 0a 0
  268. 12:430 and then we're going to parent it pit
  269. 12:47model parent is equal to EG VI port and
  270. 12:51then I'm going to create the camera is
  271. 12:54equal to instance. new camera and Camera
  272. 12:59okay so camera parent is equal to X
  273. 13:02viewport and Camera C frame is equal to
  274. 13:05C frame. new and this time I'm going to
  275. 13:08do 0 comma 0 comma and maybe Min -
  276. 13:133.3 and we'll multiply that by C frame
  277. 13:17angles and 0 Comm math rad math rad uh
  278. 13:23180 so I'm going to rotate the camera
  279. 13:25because I don't think it will be facing
  280. 13:26the right way but if it isn't facing the
  281. 13:29right way for you then just to mess
  282. 13:30around with this maybe you can rot
  283. 13:32rotate at
  284. 13:33360° uh 180 90 but for me it's going to
  285. 13:36be
  286. 13:38180 because I've tried this before and
  287. 13:41then what I'm going to do is x view Port
  288. 13:44current camera current current
  289. 13:48camera is equal to camera but now what I
  290. 13:52just realized is that we have two camera
  291. 13:54V variables up here so what I'm going to
  292. 13:57do is change this to camera pet
  293. 14:02and now it should work sorry and then
  294. 14:06the next thing I'm going to do is create
  295. 14:08a tween so I'm going to Tween the EG
  296. 14:12viewports
  297. 14:13size actually I'm sorry just do the same
  298. 14:16thing that you did here just copy this
  299. 14:18one tween right here paste it in here We
  300. 14:20R the size and then I'm going to do egg
  301. 14:24viewport do name
  302. 14:27label Dot text is equal
  303. 14:31to and chosen pet. pet name and then a
  304. 14:37viewport do name
  305. 14:40label visible is equals
  306. 14:43true and then
  307. 14:47um we will just okay so egg viewport dot
  308. 14:53Rarity
  309. 14:54label. text is equal chosen pet. Rarity
  310. 15:01and that should
  311. 15:03work and then after that we're going to
  312. 15:06do egg view Port Rarity
  313. 15:12label visible is equal to
  314. 15:16true and the next thing is weight
  315. 15:200.5.1 or Point okay 1.5 seconds is
  316. 15:23better and tween service call on create
  317. 15:27so just copy this one tween right here
  318. 15:29PED in here where we TW where we are
  319. 15:31tning the size of this but this time I'm
  320. 15:34going to put in 0.3 because it will be
  321. 15:36better and then I'm going to wait 0.3
  322. 15:39seconds so
  323. 15:40task
  324. 15:42askask wait 0.3 seconds and I'm going to
  325. 15:47change both of these visible properties
  326. 15:50to
  327. 15:51false
  328. 15:53false and this to so false
  329. 15:59and then I'm going
  330. 16:00to Loop through these
  331. 16:04again and
  332. 16:06enable everything that's not the egg
  333. 16:08system as as one thing that I forgot to
  334. 16:10do is show you how to fix this one bug
  335. 16:13so when you are looping through okay so
  336. 16:15in the X client script in the line 68
  337. 16:19when we are looping through these
  338. 16:22through the screen gys make sure that
  339. 16:23you are doing player away for child
  340. 16:26player gy going get children not script.
  341. 16:30parent going get children or this will
  342. 16:32not
  343. 16:34work now what I'm going to do up here
  344. 16:38is
  345. 16:40just okay so after doing this what I'm
  346. 16:42going to do is just uh X system asss do
  347. 16:46enabled is equal to false to true sorry
  348. 16:50and also make sure that the name label
  349. 16:51and the Rarity labels on
  350. 16:54invisible and now what I'm going to do
  351. 16:57is
  352. 16:59okay so I'm going to create a new remote
  353. 17:02event inside of inside the remotes
  354. 17:05folder so just Pat I mean remotes remote
  355. 17:10event and I'm going to call it
  356. 17:13hatag and I'm going to add I'm going to
  357. 17:17add a
  358. 17:19uh script inside of the server script
  359. 17:22service I'm going to call it
  360. 17:25X
  361. 17:27server now what I'm going to do here is
  362. 17:30okay so just paste
  363. 17:32just put this in so we're just getting
  364. 17:36the remotes the replicated storage
  365. 17:38players uh remotes and
  366. 17:41X so it's the main folder where r space
  367. 17:45not main folder workspace and then I'm
  368. 17:48going
  369. 17:48to do a debound table so I'm going to
  370. 17:51make a debound table so player uh hatch
  371. 17:56debounce debounce and an mty table and
  372. 18:00we going to create a function for
  373. 18:01choosing a random pet so choose random
  374. 18:04pet and it's going to take a pet
  375. 18:08table and what I'm going to do is local
  376. 18:10chosen pet is equal to
  377. 18:13nil and local random
  378. 18:15number is equal to math random from 1 to
  379. 18:19100 and local
  380. 18:22weight is equal to
  381. 18:25zero and for i v in pairs per table do
  382. 18:31and weit plus equal V do
  383. 18:36chance and then if we is greater or
  384. 18:40equal to random number then uh chosen
  385. 18:45pet is equal to V and break we're going
  386. 18:48to break this and then I'm going to
  387. 18:51return the chosen pet now that we've
  388. 18:52just chose a random pad we will just set
  389. 18:55up all the X so for UND
  390. 18:59comma egg and detect the input too so
  391. 19:02for underscore comma egg impairs eggs
  392. 19:06get children
  393. 19:08do and what I'm going to do is egg
  394. 19:12proximity
  395. 19:13prompt do um okay so
  396. 19:18triggered P connect
  397. 19:22function and this is going to take the
  398. 19:25player and local egg data egg data is
  399. 19:28equal to to require egg.
  400. 19:31data and local price is equal to egg
  401. 19:36data price and loc or EG
  402. 19:42price and local currency is equal to and
  403. 19:46it's going to take the egg data do
  404. 19:49currency or egg currency I don't I don't
  405. 19:52remember what we called it I think it
  406. 19:53was currency cuz it was egg
  407. 19:57currency all right so then we're going
  408. 19:59to check if player the leader stats
  409. 20:03square brackets
  410. 20:05currency is the value is greater or
  411. 20:11equal uh what am I doing greater or
  412. 20:13equal than the price if it's bigger or
  413. 20:16equal to the price then we going to do
  414. 20:19so we're going to check if not de
  415. 20:23balances uh square brackets player then
  416. 20:29then player hashd
  417. 20:32bounce uh square brackets player is
  418. 20:35equal oh play is equal to
  419. 20:39true and local chosen pet is equal to uh
  420. 20:44choose random pet we're going to call
  421. 20:45the function it's going to take the egg
  422. 20:47data data do egg pets I think egg pets
  423. 20:54yes and
  424. 20:56then player. readers tat
  425. 20:59expore brackets currency value minus
  426. 21:01equal the price and then we're going to
  427. 21:03fire the remote event so remotes hat
  428. 21:07fire client player comma name comma
  429. 21:09chosen pet and then I'm going to create
  430. 21:11a value so a value is equal to instance.
  431. 21:15new um string value and val. name is
  432. 21:19equal to uh chosen pet do name and I
  433. 21:25mean do pet name and and val. parent is
  434. 21:31equal to player.
  435. 21:34[Music]
  436. 21:36pets now I'm going to wait seven or six
  437. 21:41seconds and what I'm going to do is ler
  438. 21:44hatch D bounce squ back as player is
  439. 21:46equal to nil my defaults now what I'm
  440. 21:51going to do is players player remove any
  441. 21:53connect function and we're going to
  442. 21:55check if player hat debounce uh brackets
  443. 21:59player then player hasd bound square
  444. 22:01brackets player is equal to nil now I'm
  445. 22:03going to play this and see if anything
  446. 22:05works okay so we have main folder okay
  447. 22:08so I messed up in
  448. 22:10here it's main folder _ workspace so
  449. 22:15main folder _ workspace not main folder
  450. 22:20workspace and let's see if this is going
  451. 22:22to work no errors yet I'm going to try
  452. 22:25to patch this and we get a okay so we
  453. 22:29get in thereor and it says attempt to
  454. 22:33compare
  455. 22:34nail okay okay I think it's because we
  456. 22:39don't have any leader stats
  457. 22:41yet leader stats
  458. 22:43coins okay so we do have coins oh and I
  459. 22:47also forgot to add a folder in here
  460. 22:49called uh
  461. 22:52pets now I
  462. 22:54think let's see what's wrong with this
  463. 22:56currency is coins
  464. 23:01so attempt to
  465. 23:04compare
  466. 23:07nail okay maybe if we do do coins let's
  467. 23:11see if this is going to
  468. 23:21work okay so this is also not working so
  469. 23:23what I'm going to
  470. 23:24do is go ahead and try to find a fix
  471. 23:28this and I'll be
  472. 23:30back okay I found an easy fix for this
  473. 23:32all it was is that the price is X price
  474. 23:36with a capital E not a lowercase e so
  475. 23:41now it should
  476. 23:43work I'm want to go ahead try this
  477. 23:46out and see what errors we get now
  478. 23:50server script service attempts index
  479. 23:52with name
  480. 24:00okay so what you're going to do is
  481. 24:01change val. name to two string chosen
  482. 24:04pet. pet name make sure to add the two
  483. 24:05string and also go to the X client and
  484. 24:09what we're going to do is just put in uh
  485. 24:12remote com child hatch EG don't Cent
  486. 24:15vent con connect hatch egg and that
  487. 24:17should
  488. 24:20work and let's test this
  489. 24:24out so as you can see it does open the
  490. 24:27egg
  491. 24:29and it does that but as you can see it
  492. 24:30does that weird animation and it's very
  493. 24:32simple to fix all we got to do is
  494. 24:35just enable this make this
  495. 24:39visible I'm going to change the
  496. 24:40background trans to zero and I'm going
  497. 24:42to change the Anchor Point to
  498. 24:440.5 and the position to 0.5 comma
  499. 24:490 comma 0.5 comma
  500. 24:520 and maybe put it up a
  501. 24:55bit okay that's good enough now we can
  502. 24:58change the transparency back to one
  503. 25:02visible true enabled false and now if
  504. 25:07you play the game that should look a lot
  505. 25:09better so just play this and I'm going
  506. 25:13to go there open this up and as you can
  507. 25:17see it twns it does everything smoothly
  508. 25:21and I think this looks good now what I'm
  509. 25:23going to do
  510. 25:25is go ahead and make a door so so a door
  511. 25:28that you can
  512. 25:30unlock so I have made a
  513. 25:36door and I'm going to make this to a
  514. 25:38model and give it to you the link will
  515. 25:41be in the description and what you're
  516. 25:43going to do
  517. 25:44is okay I'm I'm going to see if I can
  518. 25:46export this right
  519. 25:51now okay so I just did that now we have
  520. 25:54a door and basically what's inside of
  521. 25:56this is an in value that's the price
  522. 25:58proximity prompt and a surface gy that
  523. 26:01displays the price uh of the door now
  524. 26:04what I'm going to do
  525. 26:06is just show you how to code the
  526. 26:10door so what I'm going to do is okay so
  527. 26:15I'm going to think about this I'm going
  528. 26:17to add a remote right
  529. 26:20here a remote which I'm going to make it
  530. 26:23a remote
  531. 26:25function and it's going to be called
  532. 26:27purchase door
  533. 26:29and we're going to have two different
  534. 26:31remote events and one of them is going
  535. 26:33to be called prompt purchase door and
  536. 26:36the other one is okay so just one I'm
  537. 26:38sorry I copied something else so add
  538. 26:41another one prompt purchase
  539. 26:44door and we're going to enter the main
  540. 26:46servers undor script and we're going to
  541. 26:48paste this in so foror commor impairs
  542. 26:51workspace domain folder main folder bace
  543. 26:55door going to get children and door.
  544. 26:59proximity parts. proximity prompt.
  545. 27:01trigger connect function and when this
  546. 27:03is triggered then we're going to just
  547. 27:05check if player if the player does not
  548. 27:06own the area first and then we're going
  549. 27:09to fire the remote event so that should
  550. 27:12work now what I'm going to do is just
  551. 27:15add a folder inside of the player data
  552. 27:17it's going to be called
  553. 27:19doors or maybe
  554. 27:22areas and I'm also going to add a folder
  555. 27:26inside of the workspace I'm going to
  556. 27:28call it
  557. 27:32doors and put the area underscore one
  558. 27:35inside the door the doors and this is
  559. 27:39basically the first door you can
  560. 27:41position it wherever you want make it
  561. 27:43bigger
  562. 27:44maybe and okay so I have that now what
  563. 27:48I'm going to do is enter a client script
  564. 27:51okay so inste of here you're going to
  565. 27:52put this in so just put this in now copy
  566. 27:56this I know it doesn't make much sense
  567. 27:58right now okay so we we are just getting
  568. 28:01replicated storage the player and the
  569. 28:04remotes but this doesn't make any sense
  570. 28:06so the main SS we don't have that yet
  571. 28:08but I'm going to show you how to make
  572. 28:10that now that that will be in the
  573. 28:12description it's a model of the UI we're
  574. 28:14going to be using I'm going to okay I'm
  575. 28:17going to go ahead and drag it
  576. 28:19into the starter gy and it's basically
  577. 28:24this it just has this would you like to
  578. 28:29purchase this area for 1.5k coins and
  579. 28:32this is all it
  580. 28:33has yeah and you can put this inside of
  581. 28:37gy and make sure that it's not visible
  582. 28:42I'm going to go back to my main client
  583. 28:43script and I'm going to change this to
  584. 28:46instead of script. parent going I do
  585. 28:48player going wa for child
  586. 28:51player guy call if your child domain SS
  587. 28:56and then the door purchase you and this
  588. 28:58is just the connection that we're going
  589. 28:59to be using later now what I'm going to
  590. 29:01do is
  591. 29:03remote do prompt purchase door client
  592. 29:07event connect function door and what I'm
  593. 29:10going to do is door purchase ui. visible
  594. 29:12is equal to
  595. 29:13true and then your purchase
  596. 29:18UI purchase text purchase
  597. 29:21text. text is equal to and would you
  598. 29:26like to purchase this area
  599. 29:30purchase
  600. 29:31purchase this area for uh space do Dot
  601. 29:36Door do price. value do Dot
  602. 29:40and face
  603. 29:43coins and then area button area button
  604. 29:47connection is equal to and door purchase
  605. 29:50UI
  606. 29:54buy Mouse button Mouse button one
  607. 29:59click one connect
  608. 30:03function and just put this in okay so
  609. 30:06loal remotes local results sorry is
  610. 30:08equal to remotes purchas door invoke
  611. 30:11server and what I'm going to do is if
  612. 30:13results is equal go true then door Go
  613. 30:15destroy so we are pretty much just going
  614. 30:18to destroy the door so that the player
  615. 30:19can go through it now and then
  616. 30:22area purchase button connection colon
  617. 30:26disconnect and after that door PR UI
  618. 30:30visible is equal to false now what if
  619. 30:32the player presses the no button close
  620. 30:36button uh what I'm going to do is close
  621. 30:38it so just do door Pur
  622. 30:42UI do close
  623. 30:45Mouse Buton one
  624. 30:50click on connect
  625. 30:53function and what I'm going to do is
  626. 30:55just okay so door Pur you y
  627. 30:58visible is equal to
  628. 31:01false now I'm going to test this out so
  629. 31:05I should be
  630. 31:08able to have an interact proxim prom
  631. 31:13right here and when I press it it should
  632. 31:14prompt this and I can close it and open
  633. 31:16it again but the buy button shouldn't
  634. 31:18work yet because we haven't scripted the
  635. 31:20server yet so I'm going to enter the
  636. 31:22main service script and what I'm going
  637. 31:25to do inside of
  638. 31:26here is is okay
  639. 31:30so game replicat
  640. 31:33storage so game replicator storage.
  641. 31:38remote purchase door door on server invo
  642. 31:40equal to function for Comm a door and
  643. 31:43want to get the actual door from the
  644. 31:45server to make sure that the door
  645. 31:47actually exists and then want to check
  646. 31:49if it is a thing so if it is a thing
  647. 31:52then we're going to check if the
  648. 31:54player's coins value is greater call
  649. 31:58then the server door. price. value then
  650. 32:01I'm going to make sure that the player
  651. 32:02does not own the door and then we will
  652. 32:06subtract the price from the players
  653. 32:08coins and then we're going to create a
  654. 32:11door value so this door value will be
  655. 32:13pretty much like the Val that we created
  656. 32:15like value that we created for
  657. 32:17DX and then we're going to return
  658. 32:23true three and lse
  659. 32:29return
  660. 32:32fults now I'm going to play this now and
  661. 32:36it should work so I should be able to
  662. 32:39purchase it but I don't think I have
  663. 32:42enough coins okay so it's 1,000 coins so
  664. 32:44I can buy it and it should throw an
  665. 32:46error and it says main fold L okay so I
  666. 32:49spent I spelled f folder wrong now it
  667. 32:54should
  668. 32:55work it should not throw any errors at
  669. 32:57me anymore so just press buy and I can
  670. 33:02go through it now
  671. 33:04great all right so what I'm going to do
  672. 33:07now is
  673. 33:09just enter my main server script and
  674. 33:13what I'm going to do is out of here when
  675. 33:14we are looping through all the doors is
  676. 33:17just do door okay so uh door do surface
  677. 33:22gy so door do surface
  678. 33:25gy do right
  679. 33:28label. text is equal to and just do
  680. 33:32door. price. value and now if you play
  681. 33:35the game it should display the price of
  682. 33:37the
  683. 33:39door and yes it does display the price
  684. 33:42of the door but we also need to put in a
  685. 33:45space and
  686. 33:50coins and now it should work okay so it
  687. 33:54works can't go through it now but we can
  688. 33:56purchase it and we can go through
  689. 33:59and yeah I think this is going to be it
  690. 34:01for today's tutorial if this helped
  691. 34:03Please Subscribe like the video share it
  692. 34:05with your friends and I'll see you all
  693. 34:06in the next video bye

About this transcript

This page contains the full transcript of [NEW]How to make A Pet Simulator X Game on Roblox - Part 2 by polarisprog, generated from the public captions YouTube serves with the video. The transcript has 4,768 words across 693 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.