YouTube2Text

How I Designed a Scalable Skill Tree System | Roblox Studio — Transcript

by Stewiepfing · 3,087 words · 462 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Over the last few days, I have been
  2. 0:01working on a little system that I think
  3. 0:03you guys will really enjoy learning
  4. 0:05about and that is my skill tree system
  5. 0:08that is heavily inspired by the one in
  6. 0:10Empire. But before I get into today's
  7. 0:12video, if you guys do go on to enjoy or
  8. 0:15learn something from this video, please
  9. 0:17leave a like and subscribe. But let's
  10. 0:18get into the skill tree.
  11. 0:21So, the first thing you will see is the
  12. 0:23skill tree area, which is made out of
  13. 0:26physical parts and there is nothing with
  14. 0:28UI in this system. So, the first
  15. 0:31question you guys might have is why
  16. 0:33would I do that? Well, one reason it
  17. 0:34just looks better because having
  18. 0:36everything 2D might look a little flat.
  19. 0:38For example, we have these glowing rings
  20. 0:40around the buttons and overall, I think
  21. 0:42using physical parts just makes it look
  22. 0:45a lot better and adds more.
  23. 0:47But this does come with a little cost
  24. 0:50and that is setting up everything. So,
  25. 0:52as you can see, we have these four
  26. 0:54buttons here, but also we have some
  27. 0:56invisible ones in their respective
  28. 0:58colors.
  29. 0:59So, we have all of these buttons and
  30. 1:01connector beams already in their folder,
  31. 1:05but you can't see all of them and the
  32. 1:07reason why I did this is I wanted to
  33. 1:09keep things as simple and easy to
  34. 1:11configure as possible without making
  35. 1:13everything complicated and having to
  36. 1:15store a lot of information about
  37. 1:17positions and how to handle the buttons.
  38. 1:21So, that is why everything is already
  39. 1:23laid out here and just the buttons
  40. 1:26that you haven't unlocked yet aren't
  41. 1:27visible and the information we do have
  42. 1:30though in these buttons is we have a
  43. 1:33connector attribute and the next node
  44. 1:36attribute. So, each node
  45. 1:39points has an attribute that points to
  46. 1:42the next node and also has a connector
  47. 1:44attribute that points to the connector
  48. 1:46that connects the next button, if that
  49. 1:49makes any sense.
  50. 1:50But if it is the last node in the tree
  51. 1:54of for the color, then the connector and
  52. 1:57next node attributes are just empty.
  53. 2:00So, going back to that cost that comes
  54. 2:03with using physical parts, a part of
  55. 2:05that is making custom systems like this
  56. 2:08custom camera drag module that controls
  57. 2:11the movement of the camera when we are
  58. 2:12in skill tree mode. And so, this is kind
  59. 2:16of lengthy,
  60. 2:17200 lines long, roughly, but it's for
  61. 2:20good reason because this module handles
  62. 2:23the camera movement on all devices.
  63. 2:26So, it's very basic. We have a start and
  64. 2:29stop function. And so, when we start the
  65. 2:32camera drag, we are just checking if
  66. 2:34there is touch enabled, like if they are
  67. 2:36on mobile, then we just hide the touch
  68. 2:38GUI to make it easier for mobile
  69. 2:40players, set the camera type and CFrame
  70. 2:42to set up the camera. And then, I am not
  71. 2:46using any connection managers, so I'm
  72. 2:49putting everything into a table and then
  73. 2:52disconnecting them later. I know
  74. 2:55I'm going to get ridiculed in the
  75. 2:56comments for that, but anyways,
  76. 2:58when we scroll with our mouse, then it
  77. 3:01controls a zoom target variable, which
  78. 3:04we will handle later on in the script. I
  79. 3:06will show you guys that. And also, mouse
  80. 3:09button one down,
  81. 3:10we are just detecting
  82. 3:12the drag and while we are dragging, then
  83. 3:15it sets this pan target variable using
  84. 3:19this delta variable and new speed.
  85. 3:22And then coming down here, once again,
  86. 3:24we are detecting if the user is on
  87. 3:26mobile. So, if user input
  88. 3:28service.gamepadenabled and if they are,
  89. 3:29then we're going to add two more
  90. 3:31connections, which is touch pan and
  91. 3:33touch pinch, which allows us to move the
  92. 3:35camera on mobile. And also, if the
  93. 3:37mobile player wants to, then they can
  94. 3:40pinch their screen and they can zoom in
  95. 3:43and out just like you would on PC with
  96. 3:45your mouse wheel.
  97. 3:47And then coming down here is where
  98. 3:49basically all the magic happens. So, in
  99. 3:51run service.prerender,
  100. 3:53remember up here we were setting zoom
  101. 3:55target and pan target.
  102. 3:58And the zoom target, well, down here is
  103. 4:01where we actually make everything smooth
  104. 4:03and resolve everything.
  105. 4:05But before we actually get to that,
  106. 4:07which is down here, we first handle
  107. 4:09console movement. So, as you can see
  108. 4:12here, if user input
  109. 4:14service.gamepadenabled,
  110. 4:15then we will set up the gamepad
  111. 4:17functionality, which I will hop in and
  112. 4:19show you guys how that works as well.
  113. 4:21But down here is where all the magic
  114. 4:24happens. So, we are basically just
  115. 4:27smoothly moving the current pan position
  116. 4:29toward the target position using lerp.
  117. 4:32So, this allows us to smoothly move our
  118. 4:35camera around and also zoom current
  119. 4:37allows us to zoom in and out smoothly.
  120. 4:41And then finally, setting the camera
  121. 4:43CFrame to all of these new values and
  122. 4:45also multiply it by the camera
  123. 4:46orientation to keep that same
  124. 4:48orientation. And then we have stop,
  125. 4:51which just disconnects everything,
  126. 4:52cleans everything up and resets
  127. 4:54everything to old values. So, there is
  128. 4:57our camera drag module.
  129. 5:00So, I was going to show you guys what
  130. 5:02the controls looked like on Xbox or a
  131. 5:05gamepad. So, here we are. Here you guys
  132. 5:08see a little preview of what everything
  133. 5:09looks like, but basically, we can use
  134. 5:11the D-pad to zoom in and out and also we
  135. 5:14can move our camera with the left
  136. 5:17joystick.
  137. 5:19And then if we wanted to actually select
  138. 5:21something, then we'd use the virtual
  139. 5:22cursor and also the camera moves with
  140. 5:25that as well. And then we would
  141. 5:27hold down the right trigger to
  142. 5:30activate the buttons and buy new ones if
  143. 5:32we wanted to.
  144. 5:34[Music]
  145. 5:36So, now let's get into the actual
  146. 5:38buttons we have here. So, how are these
  147. 5:40being handled? Well, for this system, I
  148. 5:43use a custom click detector module
  149. 5:46instead of regular click detectors and
  150. 5:48why I do this is because this module has
  151. 5:51more events that the regular click
  152. 5:53detector does not. For example, mouse
  153. 5:55down and mouse up. So, if I were to hold
  154. 5:58down my mouse over the button, then it
  155. 5:59works and if I release it, then that
  156. 6:02works as well.
  157. 6:03And it's very easy to use, too. So, if I
  158. 6:06open up my skill tree client script and
  159. 6:08go down to here where we handle it, we
  160. 6:10just loop through all the nodes and then
  161. 6:14find the base and then make a new
  162. 6:16detector and then just make it so when
  163. 6:20we have our mouse entering the base,
  164. 6:23then it works. Mouse leave, mouse down
  165. 6:25and then mouse up and then we tween the
  166. 6:29button.
  167. 6:30And yes, these buttons are models. So,
  168. 6:32how we are doing that, I know there's
  169. 6:34modules for this, but we're doing it the
  170. 6:36hard way. We have this tween scale
  171. 6:38function where it takes in the model and
  172. 6:40the target scale and uses run service
  173. 6:43along with tween service to smoothly
  174. 6:46scale the button. So, there's that
  175. 6:48function here.
  176. 6:51But while I was testing this on mobile,
  177. 6:53it was kind of hard to actually click
  178. 6:56the buttons because a lot of times it
  179. 6:58wasn't registering, so I didn't know if
  180. 6:59it was with the module or something like
  181. 7:01that. So, to fix that,
  182. 7:05that is where this part of the code
  183. 7:08comes into play.
  184. 7:09So, basically, what this get part from
  185. 7:11touch function is doing is given a
  186. 7:14screen position or touch position, it
  187. 7:16tells us what 3D object the player is
  188. 7:19actually touching.
  189. 7:20So, touch position is 2D, so we send it
  190. 7:24here into screen point to ray, so we
  191. 7:26convert that screen point into a ray
  192. 7:29that shoots out of the camera. So, then
  193. 7:31we have this unit ray variable. And then
  194. 7:33we use ray casting to actually get the
  195. 7:35part. So, here we shoot a ray from the
  196. 7:38unit ray's origin and then send it in
  197. 7:40the direction and then we multiply it
  198. 7:42times 1,000, so we actually hit it,
  199. 7:44which 1,000's probably overkill, but it
  200. 7:47works and
  201. 7:49then we send in our parameters, which
  202. 7:51don't think I need respect can collide
  203. 7:53because I was just testing with that.
  204. 7:55But basically, here we have it set to
  205. 7:57ray cast filter type include, so it
  206. 7:59includes all of these nodes and so we
  207. 8:02get that ray cast and return the result.
  208. 8:05And then down here, when there is
  209. 8:08movement or touch on the screen, then we
  210. 8:11get the result from get part from touch
  211. 8:14and check if there actually is result
  212. 8:16and there's an instance to it, then we
  213. 8:18find that node and make sure the node
  214. 8:20exists and if it does, then reset active
  215. 8:24node to our touch node to that node,
  216. 8:26tween the node and then send a packet,
  217. 8:29which I'll go over here in just a
  218. 8:30second. And then touch ended just
  219. 8:32handles that with tween scale and then
  220. 8:35set active touch node back to nil.
  221. 8:38So, now let's follow this little
  222. 8:39pipeline we have here. In both of these
  223. 8:41parts of the code, we are sending the
  224. 8:44skill tree info packet to the server and
  225. 8:47we are sending the node name. So, on the
  226. 8:50server, we pick that up and here's the
  227. 8:53skill name.
  228. 8:54So, we are just checking if the player
  229. 8:56already owns that skill, then we just
  230. 8:59warn already owned and return. And if
  231. 9:02they don't already have it owned, then
  232. 9:04we check if they have the prerequisites.
  233. 9:08And so, that means it checks to see if
  234. 9:10we have the other buttons before that
  235. 9:12unlocked. And how we do that is we have
  236. 9:14a module called skill tree data and this
  237. 9:17is probably isn't set up in the best
  238. 9:19way, but it gets the job done.
  239. 9:21Basically, these are all of the buttons
  240. 9:24and they are titled with their names and
  241. 9:26they each have an ID, what branch
  242. 9:28they're part of, which is the color, and
  243. 9:31the prerequisites, which is a table that
  244. 9:33points to the ID of what you need to
  245. 9:35have already owned. And then we have the
  246. 9:38cost. So, if I wanted to have defense or
  247. 9:40try and buy defense, then I would have
  248. 9:43to have jump height and walk speed
  249. 9:44already unlocked. So, that's pretty
  250. 9:46self-explanatory.
  251. 9:48So, it just checks that and so, if we
  252. 9:50don't have those already owned, then
  253. 9:53once again, we warn and return, so
  254. 9:55everything down here doesn't run. But
  255. 9:57then, we check in the data manager,
  256. 9:59which has more to do with
  257. 10:02data stores, which I will also get into.
  258. 10:04So, sit tight for that. So, we're just
  259. 10:06checking if we have enough skill points
  260. 10:08for that for the cost. And if we do,
  261. 10:11then we manage the skills, which is
  262. 10:13basically add or subtract.
  263. 10:16Or no, sorry, sorry. That's this. Okay,
  264. 10:18so manage skills, we send in the player
  265. 10:20and the skill name. So, now we just make
  266. 10:22it so the player owns the skill and
  267. 10:24manage skill points is where we actually
  268. 10:26take away the cost or the number of
  269. 10:29skill points away from the player. And
  270. 10:31then, we fire another packet back to the
  271. 10:33client.
  272. 10:35And so then, what happens when we return
  273. 10:37back to the client is down here,
  274. 10:40we get the actual node model
  275. 10:44using the skill name that we sent. We
  276. 10:46get the base, and then we set the color
  277. 10:48of the base. We then get a little
  278. 10:50sparkle particle that plays for a nice
  279. 10:52little effect. And then,
  280. 10:55remember the next node attribute, we get
  281. 10:58the next node attribute inside of the
  282. 11:00node and then find the next node
  283. 11:02physical model, and we set that so that
  284. 11:05it's visible and we can see it. Now,
  285. 11:07down here, this is just another little
  286. 11:09effect to show that we own the button.
  287. 11:11It's a little shine effect, which I
  288. 11:13should probably put back up here the
  289. 11:15sparkles, but you know,
  290. 11:17it's right there. And then,
  291. 11:19we set the surface GUI
  292. 11:22GUI. All right. Surface GUI
  293. 11:25of that next node equal to true so we
  294. 11:27can also see that. And then, get the
  295. 11:30connector attribute, get that actual
  296. 11:32connector, and set the beams enabled
  297. 11:35property of that connector equal to
  298. 11:37true.
  299. 11:38And so, if you guys want a little bit
  300. 11:40more information on the connector parts,
  301. 11:42well, here we have connector one and
  302. 11:44two, and basically, it's just a part and
  303. 11:48these two attachments are in it
  304. 11:50is what basically controls the beam. So,
  305. 11:53the first one or well,
  306. 11:55this should be number one, but
  307. 11:57basically, the one attachment is in the
  308. 12:00middle of the one point or one base, and
  309. 12:03then the other attachment is in the
  310. 12:04center of the other one. And here's our
  311. 12:06beam that just connects them. So, pretty
  312. 12:08simple.
  313. 12:10So, now let's get more into data saving
  314. 12:13and stuff like that. So, for this, I am
  315. 12:16obviously obviously using profile store
  316. 12:19because it's just easy and literally has
  317. 12:21everything for you already built into
  318. 12:23it. So, let's take a look at stats.
  319. 12:25Here, the stats are just setting up the
  320. 12:28skill points, the skill tree folder in
  321. 12:30the player, and then also a folder for
  322. 12:33each of the colors. And then,
  323. 12:36we are sending a packet, which I will
  324. 12:38also explain. But first, we're waiting 1
  325. 12:40second to make sure everything is loaded
  326. 12:42because if I didn't have this here, it
  327. 12:44was breaking. So, then the simple task
  328. 12:46that await worked. And so after we send
  329. 12:49that packet, we are looping through all
  330. 12:51of the owned skills in the player skill
  331. 12:54tree and making strings and setting the
  332. 12:58parent of that string to the color, the
  333. 13:01correct color folder.
  334. 13:03So, going ahead and looking at the
  335. 13:06client, looking at skill tree joint
  336. 13:08packet, this just makes it so everything
  337. 13:11is set up when the player joins the
  338. 13:13game. So, we send all of the player's
  339. 13:16own skills back over here. And then, we
  340. 13:19convert this own skills table or list
  341. 13:22into a dictionary
  342. 13:24because later on, we will loop through
  343. 13:26everything, but checking a list is can
  344. 13:29be slow, but it would be more slow if we
  345. 13:32had more skills. So, we're just setting
  346. 13:33up everything into a dictionary so
  347. 13:35everything is faster. And if you've
  348. 13:37watched my other videos, you know that
  349. 13:40direct lookup is big O of one.
  350. 13:43And so then down here, it's basically
  351. 13:45doing exactly what I explained before,
  352. 13:48where we find the node, find the base
  353. 13:49and the ring, set the base color and the
  354. 13:51transparency, add the shine particle,
  355. 13:55and make it so we can see the surface
  356. 13:56GUI. And then, when we come down here,
  357. 14:00this is where we enable connections and
  358. 14:02reveal the next skill. So, we loop
  359. 14:04again. I know loop, I know I'm
  360. 14:06contradicting myself, but just give me a
  361. 14:08minute, all right? So, we're looping
  362. 14:09through all of the skills in the owned
  363. 14:12lookup.
  364. 14:13And so here,
  365. 14:15we are getting the node, and then the
  366. 14:18next node
  367. 14:20attribute and also the connector name
  368. 14:22attribute. And then, we come down here
  369. 14:24and get that next node and also get the
  370. 14:26connector and set that equal to true.
  371. 14:29And then finally, we come down here and
  372. 14:32look up the next node and get that next
  373. 14:36node base and a ring, set the
  374. 14:38transparency so we can see it, and also
  375. 14:41set the surface GUI. So, why are we
  376. 14:43doing this? Well,
  377. 14:45if we just spawned or made everything
  378. 14:47visible that we owned, then how are we
  379. 14:50supposed to keep expanding the skill
  380. 14:52tree if we don't have everything? So,
  381. 14:53that's why down here, we get the next
  382. 14:56node and the connector, so then we can
  383. 14:58see that and be able to keep growing the
  384. 15:01skill tree if we don't have it fully
  385. 15:02unlocked.
  386. 15:04And so that is also why we aren't
  387. 15:05setting the color of the base because we
  388. 15:07don't own it. So, you know, there we go.
  389. 15:10So yeah, guys, that is pretty much my
  390. 15:12little skill tree project here. I'm now
  391. 15:14going to go in and basically just play
  392. 15:17around with it more so you guys can see
  393. 15:19it. So,
  394. 15:20again, there's the camera drag with the
  395. 15:22smooth movement and scrolling. And as
  396. 15:25you can see, the shine particle
  397. 15:28works just fine and is very cool. And
  398. 15:31then as you can see, like I just
  399. 15:33explained, it shows the connector and
  400. 15:36the next node so then we can keep
  401. 15:39growing the skill tree.
  402. 15:40And I believe I have enough points, so I
  403. 15:42can just check that again. All right, I
  404. 15:44have 19. So, if I wanted to buy a new
  405. 15:47node,
  406. 15:50and there we go.
  407. 15:53If I come over here,
  408. 15:56and I can buy
  409. 15:57the rest of the nodes
  410. 16:00just like that. There we go.
  411. 16:03And I'm a little unsure on why these
  412. 16:06aren't working with the particles, but
  413. 16:08you know, this system isn't completely
  414. 16:09done because
  415. 16:11these buttons don't actually do anything
  416. 16:13when you buy them cuz this isn't an
  417. 16:15actual game. This was just for
  418. 16:17a little
  419. 16:19practice and fun. So,
  420. 16:22these don't actually give you anything,
  421. 16:24but if it were an actual game, it
  422. 16:25wouldn't be hard to do that. But there
  423. 16:27we go. This is the full skill tree
  424. 16:30done.
  425. 16:33Okay, guys. So, I just took a little
  426. 16:36break to take a look at my code again,
  427. 16:38and I think I figured out why the shine
  428. 16:41wasn't working.
  429. 16:43And it's because it was only not working
  430. 16:46on the last button of the branch. So,
  431. 16:50if I were to buy the green one down
  432. 16:53here,
  433. 16:55that would start working. But if I were
  434. 16:57to buy this, then that wouldn't work.
  435. 17:00And that's because I would clone the
  436. 17:02shine after I would check for next node.
  437. 17:05And so since
  438. 17:07the last button in the tree doesn't have
  439. 17:09a next node or doesn't point to a next
  440. 17:12node, then it won't run. So, all I would
  441. 17:14have to do
  442. 17:16is
  443. 17:17[Music]
  444. 17:18copy this
  445. 17:20and put it
  446. 17:22before that. So, let's go ahead and try
  447. 17:24that again.
  448. 17:26If I were to buy that,
  449. 17:28that would work.
  450. 17:30That would work.
  451. 17:33And that would work. There we go.
  452. 17:35Just like that. So, let me go ahead and
  453. 17:37fill out the entire thing now.
  454. 17:39There is the entire skill tree once
  455. 17:41again.
  456. 17:43[Music]
  457. 17:45And so yeah, guys, this was today's
  458. 17:47video. If you guys did learn something
  459. 17:49from this video or you guys enjoyed this
  460. 17:50video, please hit the like button and
  461. 17:53subscribe button. I will see you guys in
  462. 17:55the next video, and peace.

About this transcript

This page contains the full transcript of How I Designed a Scalable Skill Tree System | Roblox Studio by Stewiepfing, generated from the public captions YouTube serves with the video. The transcript has 3,087 words across 462 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.