YouTube2Text

Debugging Guide for Beginners in Roblox Studio — Transcript

by Driple Studios · 2,692 words · 416 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hey everyone, welcome back to the
  2. 0:01channel. Today's video is for every
  3. 0:02beginner developer who has ever stared
  4. 0:05at their screen thinking what is my game
  5. 0:06broken? I remember reading a comment a
  6. 0:08while ago from someone who said that
  7. 0:10they were trying to learn game
  8. 0:11development through Roblox to try and
  9. 0:13earn some money on the side
  10. 0:15and put that towards funds for starting
  11. 0:17their own business one day. First of
  12. 0:19all, that is awesome. But if you are
  13. 0:21learning to code, especially as a
  14. 0:22beginner, bugs can feel absolutely
  15. 0:24impossible to solve and it can be one of
  16. 0:26those hurdles that makes people quit.
  17. 0:29So, in this video, I'm going to show you
  18. 0:30how developers actually fix bugs, the
  19. 0:33most common beginner mistakes, and a
  20. 0:35step-by-step process that you can use
  21. 0:37even if you have absolutely no clue
  22. 0:39what's happening. And trust me, every
  23. 0:41single developer, even experienced ones,
  24. 0:43deal with bugs every single day. The
  25. 0:46first thing beginners need to understand
  26. 0:47is this, bugs are normal. A bug does not
  27. 0:51mean that you're bad at coding, or your
  28. 0:53game is ruined, or you should quit.
  29. 0:55Professional developers spend hours
  30. 0:57debugging, which just goes to show that
  31. 0:59really the skill isn't never making bugs
  32. 1:01and making perfect code, it's learning
  33. 1:04how to use problem solving to overcome
  34. 1:07any bugs.
  35. 1:08If your game is broken and you are not
  36. 1:10checking the output window, you're
  37. 1:11basically trying to drive with your eyes
  38. 1:13closed. The output tells you your script
  39. 1:15errors, any warnings, line numbers, and
  40. 1:18sometimes exactly what went wrong. To
  41. 1:20open the output, just go to script and
  42. 1:22click output. You get this output window
  43. 1:25and you can size it however you want,
  44. 1:26place it wherever you want. I leave it
  45. 1:28at the bottom of my screen.
  46. 1:30And now, whenever you press test, any
  47. 1:32errors or output logs will appear in
  48. 1:35your output window.
  49. 1:37I'm going to go through a couple of
  50. 1:38example bugs. This first one is a nil
  51. 1:40value error. So, the broken code is
  52. 1:42local part is workspace.redpart,
  53. 1:45part.transparency is 0.5. This script
  54. 1:48looks fine, but if the part doesn't
  55. 1:50exist, Roblox throws an error. Let's try
  56. 1:52it.
  57. 1:53RedPart is not a valid member of
  58. 1:55workspace workspace.
  59. 1:57So, what this really means is Roblox is
  60. 1:59trying to find something named red part
  61. 2:01inside of workspace. However, when we
  62. 2:04run the game, it never finds anything
  63. 2:06named red part inside of the workspace.
  64. 2:08If we look in the workspace, there is
  65. 2:10nothing named red part. Hence, we get
  66. 2:12the error, red part is not a valid
  67. 2:14member of workspace, workspace. In other
  68. 2:17words, red part does not exist inside of
  69. 2:20the workspace.
  70. 2:22Another error you might encounter, if we
  71. 2:23set part equal to nil
  72. 2:26and press play,
  73. 2:28attempt to index nil with transparency.
  74. 2:31So, this is a similar error. This error
  75. 2:33means that we are trying to access the
  76. 2:35transparency property on part, but part
  77. 2:39is nil.
  78. 2:40So, let me put this back to how it was.
  79. 2:42So, if we are trying to access
  80. 2:44transparency on an object that isn't
  81. 2:46there,
  82. 2:47then we are going to get this attempt to
  83. 2:49index nil with error. And that means
  84. 2:52that whatever we are trying to access
  85. 2:55doesn't exist. So, to fix this, let's
  86. 2:58use find first child on red part. We can
  87. 3:01do workspace colon find first child red
  88. 3:03part.
  89. 3:06And this will check if the child exists
  90. 3:08or not. If it does, it will return the
  91. 3:10part. If it doesn't, it will just set
  92. 3:12part equal to nil.
  93. 3:13And now we will get that
  94. 3:14part.transparency, the attempt index nil
  95. 3:17error. So, how can we fix the
  96. 3:19part.transparency? We need to check if
  97. 3:21the part exists. So, a simple fix would
  98. 3:23be to use an if statement. If part then
  99. 3:26If the part exists, then we can set
  100. 3:28part.transparency
  101. 3:30to 0.5.
  102. 3:32else
  103. 3:34We can put a warning in the output using
  104. 3:36the warn keyword, something maybe like
  105. 3:39red part was not found.
  106. 3:42I'll remove this line now at the end.
  107. 3:44Now, when we run this, it says red part
  108. 3:46was not found.
  109. 3:48So, we've now turned that error that was
  110. 3:50breaking the code into something that's
  111. 3:52manageable, and this is just a log to
  112. 3:54let us know the red part was not found.
  113. 3:57So, now instead of crashing, the script
  114. 3:59safely checks if the object exists
  115. 4:01first. One of the easiest debugging
  116. 4:03tools ever is literally just print.
  117. 4:07For example, I can type in print
  118. 4:10script started.
  119. 4:12Now, when I press play, I get a debug
  120. 4:15log which says script started.
  121. 4:18Beginners often write huge scripts and
  122. 4:20have no idea where the problem is. So,
  123. 4:22instead, track what's happening. For
  124. 4:24example, let's print button clicked.
  125. 4:28And then we're going to set coins equal
  126. 4:29to 100.
  127. 4:31Now, let's print the number of coins we
  128. 4:32have.
  129. 4:33Let's add 50.
  130. 4:37And then let's print the coins again.
  131. 4:39Now, when we run this, we have button
  132. 4:41clicked 100, then 150.
  133. 4:44So, this lets you see
  134. 4:46did the code run, first of all?
  135. 4:49If button click is printing, then yes,
  136. 4:51the code has run.
  137. 4:53Did the value change? If the coins here
  138. 4:55is different to the coins here, we know
  139. 4:57that plus equals 50 has worked.
  140. 4:59And which part broke, if any?
  141. 5:02A pro tip I would give is to use warn,
  142. 5:04because warn is useful because it
  143. 5:06appears in yellow in the output window
  144. 5:09and is easier to spot. So, rather than
  145. 5:11printing coins and printing button
  146. 5:12clicked, I could warn button clicked. I
  147. 5:15could warn the coins, and I could warn
  148. 5:17the coins again. And now it's just a bit
  149. 5:19easier to spot in the output. I usually
  150. 5:22only use warnings if something genuinely
  151. 5:24has gone wrong in the code, and not for
  152. 5:26debugging, because a debug is only
  153. 5:29temporary. I'm only going to leave a
  154. 5:30temporary print in there if I'm
  155. 5:33debugging. I'm not going to leave it in
  156. 5:34there permanent. I just want to cover
  157. 5:36some of the most common beginner bugs.
  158. 5:39So, the most common bug that I see in
  159. 5:40our Discord server when people are
  160. 5:42asking for help and in the comments of
  161. 5:43videos, are misspelling names.
  162. 5:46This one gets everyone. Let me write
  163. 5:48some example code here. Let me add a
  164. 5:50part to the workspace.
  165. 5:52I'll just leave it named part and I want
  166. 5:54to change its brick color to bright red.
  167. 5:56I'm going to say
  168. 5:57workspace.part.brickcolor
  169. 6:01= brickcolor
  170. 6:05.new and I'm going to give it bright
  171. 6:08red.
  172. 6:10Let's run this.
  173. 6:12Part is not a valid member of workspace
  174. 6:14workspace. But let's look at the
  175. 6:16workspace. The part is a valid member of
  176. 6:18the workspace. So why am I getting this
  177. 6:20error? Well, the reason for this error
  178. 6:23we can see it's coming from the script
  179. 6:25named buggy code, which is this script
  180. 6:27here.
  181. 6:28And it's coming on line one. That's what
  182. 6:29the colon one means. So it's on line
  183. 6:32one.
  184. 6:33Let's have a look.
  185. 6:35What I can see here, I've misspelled
  186. 6:36part. In the workspace, it's p a r t and
  187. 6:40in here I've put p a r double t. So
  188. 6:42let's remove one of those t's. I'll just
  189. 6:43retype it.
  190. 6:45And let's run it again.
  191. 6:47I'm still getting the error. Part is not
  192. 6:49a valid member of workspace workspace.
  193. 6:51Quickly pause the video and see if you
  194. 6:53can spot what is causing this error.
  195. 6:56Hopefully you gave that a go.
  196. 6:58So, let's have a look.
  197. 7:01As we can see, it's spelled p a r t and
  198. 7:03I spelled it p a r t here. However, in
  199. 7:05the workspace, I have an upper case p
  200. 7:08and in the code, it's all lower case.
  201. 7:10The capitalization is very important. It
  202. 7:13must match exactly. So I need to have an
  203. 7:15upper case p and then all lower case a r
  204. 7:17t.
  205. 7:18And now if I run this, it will set the
  206. 7:20brick color to bright red.
  207. 7:22And there we can see that one letter has
  208. 7:24broken the entire thing.
  209. 7:26This next bug confuses beginners
  210. 7:28constantly and that is local scripts and
  211. 7:30scripts. Local scripts run on the
  212. 7:32player's computer. Normal scripts run on
  213. 7:35the server. I'm going to add to starter
  214. 7:38player scripts a local script.
  215. 7:41And I'm going to say
  216. 7:41game.players.playeradded
  217. 7:45colon connect
  218. 7:47function passing through the player that
  219. 7:48joined. I'll just print the player.name.
  220. 7:51So, usually in the server script, this
  221. 7:53code would run every time a player joins
  222. 7:55the server, and it would just print the
  223. 7:56name of the player. I'll put this local
  224. 7:58script in ServerScriptService.
  225. 8:01We can see no output runs.
  226. 8:04Now, let's put the local script where it
  227. 8:05should be in StarterPlayerScripts.
  228. 8:08And we still get no output. And that is
  229. 8:10because this is linked to the server.
  230. 8:12It's not something that runs on the
  231. 8:14player's machine. It runs on the server.
  232. 8:17So, this has to be in a server script.
  233. 8:19PlayerAdded won't work properly inside a
  234. 8:21local script like this.
  235. 8:23So, let's put it inside a normal script.
  236. 8:25I'm going to add a script to
  237. 8:26ServerScriptService named fixed script.
  238. 8:30And I'm just going to copy all the code
  239. 8:31and paste it into the fixed script.
  240. 8:35Now, when we run it,
  241. 8:37it prints out my username perfectly.
  242. 8:39I'll delete those two scripts now.
  243. 8:42Another one is infinite yields. So, this
  244. 8:45is a very, very easy one to
  245. 8:49notice, but sometimes it can be a bit
  246. 8:52hard to figure out why it's happening.
  247. 8:54You usually get this when you use
  248. 8:56WaitForChild. Let me write local part
  249. 8:59equals workspace colon WaitForChild. I'm
  250. 9:02going to wait for part.
  251. 9:05Now, I don't have a part in my
  252. 9:06workspace. Let's just run this and see
  253. 9:08what happens.
  254. 9:09At first, we don't get anything. After
  255. 9:12waiting a few seconds, we get something
  256. 9:14that says infinite yield possible on
  257. 9:17workspace colon WaitForChild part. If
  258. 9:20Roblox says infinite yield possible, it
  259. 9:22means the object is taking too long to
  260. 9:25appear. Usually,
  261. 9:27this means that the object name is
  262. 9:28wrong, it was deleted, or it's in the
  263. 9:31wrong location.
  264. 9:33To fix this, I'm just going to add part
  265. 9:35to my workspace. And now, nothing will
  266. 9:38output. I'll give it a few seconds and
  267. 9:41we won't get that infinite yield because
  268. 9:42it will successfully find that part now
  269. 9:45in the workspace.
  270. 9:47So, infinite yield just means
  271. 9:49double-check the object name. It might
  272. 9:51be spelled wrong, similar to what we had
  273. 9:53earlier in bug one.
  274. 9:56It was maybe deleted in runtime by
  275. 9:59another script or maybe it's in the
  276. 10:01wrong location. Maybe the part we're
  277. 10:03looking for isn't in the workspace, but
  278. 10:05maybe it's actually in the replicated
  279. 10:07storage. The fourth bug I see sometimes
  280. 10:10is variables not updating.
  281. 10:12Let me write some broken code here. I'm
  282. 10:14going to initialize a variable named
  283. 10:16zero. It's going to be a local variable,
  284. 10:18but it's local to the entire script, so
  285. 10:20it's effectively global.
  286. 10:22And I'm going to create a local function
  287. 10:24and I'll name this add coins. Inside of
  288. 10:27this function, I'll say local coins
  289. 10:29equals coins plus 10.
  290. 10:31This creates a new variable. Now, it's a
  291. 10:34bit harder to see what the problem is
  292. 10:35here. But, what is happening here is
  293. 10:37this is creating a new variable instead
  294. 10:40of updating the original. The fix would
  295. 10:43be to remove this local keyword in the
  296. 10:45function and just do coins equals coins
  297. 10:48plus 10.
  298. 10:49This changes the original variable
  299. 10:51correctly. When we use local in a
  300. 10:53function, it's creating a brand new
  301. 10:54variable to the original.
  302. 10:57Now, let me show you the actual process
  303. 10:59that most developers use. The first step
  304. 11:01is not to panic. If your game breaks,
  305. 11:03don't instantly rewrite everything.
  306. 11:06Read the error. That's step two. Read
  307. 11:08the error. Most beginners skip this
  308. 11:10completely. The output usually tells you
  309. 11:13what broke, where it broke, and
  310. 11:14sometimes why. Let's review one of those
  311. 11:17error messages from earlier. I'm going
  312. 11:19to force an error. I'm going to say part
  313. 11:22equals nil and then say
  314. 11:24part.transparency
  315. 11:25equals 0.5. I believe this was one of
  316. 11:28our examples earlier. Let's run this.
  317. 11:33So, the output tells you what broke. So,
  318. 11:36attempt to index nil with transparency,
  319. 11:38that's broken. Where it broke? Well, it
  320. 11:40broke Well, it broke in the script named
  321. 11:42buggy code on line three. You can also
  322. 11:44see that just here. It says server
  323. 11:46script and it broke on buggy code line
  324. 11:49three. So, we're going to look for that
  325. 11:51script, which is in server script
  326. 11:53service. So, in server script service,
  327. 11:55I've got a script named buggy code and
  328. 11:57on line three, I'm getting that error.
  329. 12:00And sometimes you why it broke. In our
  330. 12:02case, it says it's attempt to index nil.
  331. 12:04So, that tells me that we are trying to
  332. 12:06access the transparency property on
  333. 12:08part, but part is nil. So, part doesn't
  334. 12:11exist. That is step three as well, which
  335. 12:13is finding the exact line. So, line
  336. 12:16three.
  337. 12:16Step four is to test smaller pieces. For
  338. 12:19example, I could print before
  339. 12:22transparency, I could print the part
  340. 12:24just to make sure a part does exist. And
  341. 12:26then afterwards, I could print the part
  342. 12:28again just to check if part still exists
  343. 12:31after we change the transparency. In my
  344. 12:33case, I can see that it prints nil and
  345. 12:35then I get the error and the second
  346. 12:37print never prints because that error is
  347. 12:40preventing it on line five from ever
  348. 12:42reaching to line seven.
  349. 12:44So, I can see that it's breaking at line
  350. 12:46five, but my print part is allowing me
  351. 12:49to see that the part is actually nil.
  352. 12:51So, that's why I know that part is nil.
  353. 12:54I can tell it's wrong based on this
  354. 12:56print statement.
  355. 12:57A better example would be something like
  356. 12:59this. Let's print a statement before the
  357. 13:01function call and then print one after
  358. 13:03the function call. And if after function
  359. 13:06never prints, then you know the problem
  360. 13:08happened inside of open door. So, if I
  361. 13:11was to run this, after function never
  362. 13:13prints. So, we know the problem is
  363. 13:15inside of that function.
  364. 13:18In my case, the problem here is that
  365. 13:19I've not actually defined the function,
  366. 13:21so there is no code to run. The fifth
  367. 13:23step is just to change one thing at a
  368. 13:25time. Beginners often change 20 things
  369. 13:27at once, then they don't know what fixed
  370. 13:30the bug or what made it worse. Just fix
  371. 13:32one thing, test it. If it's still not
  372. 13:34working, fix another. If it is working,
  373. 13:36then happy days. You don't need to do
  374. 13:38much more.
  375. 13:39A lot of programming comes down to
  376. 13:40keeping a positive mindset, staying
  377. 13:42motivated and disciplined to actually
  378. 13:44get projects done. The number of
  379. 13:46projects I've started and never finished
  380. 13:48because I just thought, "Ah, I'm a bit
  381. 13:50bored now." Or, "Ah, that code's not
  382. 13:52working very well." And that's okay to
  383. 13:54have those drop-offs every now and then.
  384. 13:57But, the best developers stay
  385. 13:58consistent. They learn from their
  386. 14:00mistakes. And that is what programming
  387. 14:02is all about. It's all about
  388. 14:03problem-solving and going from A to B to
  389. 14:06C to D. Anyone that makes that jump from
  390. 14:08A to Z straight away, well, they're
  391. 14:10going to have 24 other letters that are
  392. 14:12going to be problematic. Whereas, if you
  393. 14:14focus on one letter at a time, one step
  394. 14:17at a time, you're going to get there in
  395. 14:19a much stronger way.
  396. 14:21So, if this video helped you, make sure
  397. 14:23to subscribe because we're uploading
  398. 14:25Roblox development videos every few
  399. 14:27days, as well as expanding to some new
  400. 14:29game engines. Comment below what the
  401. 14:31most confusing bug is that you've ever
  402. 14:33had in Roblox Studio.
  403. 14:35Also, join our Discord server, which you
  404. 14:37can find the link to in the description,
  405. 14:39because the over there you can actually
  406. 14:40post if you're having any problems with
  407. 14:42your games, if you're having any bugs.
  408. 14:45We've got a community of people, and
  409. 14:47we're trying to build that community.
  410. 14:49And we're all happy to help each other
  411. 14:51with our programming over there. You can
  412. 14:52also leave feedback on our videos, which
  413. 14:54is always highly recommended, and we
  414. 14:57really appreciate it. Thanks for
  415. 14:59watching, and I will see you in the next
  416. 15:01one.

About this transcript

This page contains the full transcript of Debugging Guide for Beginners in Roblox Studio by Driple Studios, generated from the public captions YouTube serves with the video. The transcript has 2,692 words across 416 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.