Debugging Guide for Beginners in Roblox Studio — Transcript
Full transcript
- 0:00Hey everyone, welcome back to the
- 0:01channel. Today's video is for every
- 0:02beginner developer who has ever stared
- 0:05at their screen thinking what is my game
- 0:06broken? I remember reading a comment a
- 0:08while ago from someone who said that
- 0:10they were trying to learn game
- 0:11development through Roblox to try and
- 0:13earn some money on the side
- 0:15and put that towards funds for starting
- 0:17their own business one day. First of
- 0:19all, that is awesome. But if you are
- 0:21learning to code, especially as a
- 0:22beginner, bugs can feel absolutely
- 0:24impossible to solve and it can be one of
- 0:26those hurdles that makes people quit.
- 0:29So, in this video, I'm going to show you
- 0:30how developers actually fix bugs, the
- 0:33most common beginner mistakes, and a
- 0:35step-by-step process that you can use
- 0:37even if you have absolutely no clue
- 0:39what's happening. And trust me, every
- 0:41single developer, even experienced ones,
- 0:43deal with bugs every single day. The
- 0:46first thing beginners need to understand
- 0:47is this, bugs are normal. A bug does not
- 0:51mean that you're bad at coding, or your
- 0:53game is ruined, or you should quit.
- 0:55Professional developers spend hours
- 0:57debugging, which just goes to show that
- 0:59really the skill isn't never making bugs
- 1:01and making perfect code, it's learning
- 1:04how to use problem solving to overcome
- 1:07any bugs.
- 1:08If your game is broken and you are not
- 1:10checking the output window, you're
- 1:11basically trying to drive with your eyes
- 1:13closed. The output tells you your script
- 1:15errors, any warnings, line numbers, and
- 1:18sometimes exactly what went wrong. To
- 1:20open the output, just go to script and
- 1:22click output. You get this output window
- 1:25and you can size it however you want,
- 1:26place it wherever you want. I leave it
- 1:28at the bottom of my screen.
- 1:30And now, whenever you press test, any
- 1:32errors or output logs will appear in
- 1:35your output window.
- 1:37I'm going to go through a couple of
- 1:38example bugs. This first one is a nil
- 1:40value error. So, the broken code is
- 1:42local part is workspace.redpart,
- 1:45part.transparency is 0.5. This script
- 1:48looks fine, but if the part doesn't
- 1:50exist, Roblox throws an error. Let's try
- 1:52it.
- 1:53RedPart is not a valid member of
- 1:55workspace workspace.
- 1:57So, what this really means is Roblox is
- 1:59trying to find something named red part
- 2:01inside of workspace. However, when we
- 2:04run the game, it never finds anything
- 2:06named red part inside of the workspace.
- 2:08If we look in the workspace, there is
- 2:10nothing named red part. Hence, we get
- 2:12the error, red part is not a valid
- 2:14member of workspace, workspace. In other
- 2:17words, red part does not exist inside of
- 2:20the workspace.
- 2:22Another error you might encounter, if we
- 2:23set part equal to nil
- 2:26and press play,
- 2:28attempt to index nil with transparency.
- 2:31So, this is a similar error. This error
- 2:33means that we are trying to access the
- 2:35transparency property on part, but part
- 2:39is nil.
- 2:40So, let me put this back to how it was.
- 2:42So, if we are trying to access
- 2:44transparency on an object that isn't
- 2:46there,
- 2:47then we are going to get this attempt to
- 2:49index nil with error. And that means
- 2:52that whatever we are trying to access
- 2:55doesn't exist. So, to fix this, let's
- 2:58use find first child on red part. We can
- 3:01do workspace colon find first child red
- 3:03part.
- 3:06And this will check if the child exists
- 3:08or not. If it does, it will return the
- 3:10part. If it doesn't, it will just set
- 3:12part equal to nil.
- 3:13And now we will get that
- 3:14part.transparency, the attempt index nil
- 3:17error. So, how can we fix the
- 3:19part.transparency? We need to check if
- 3:21the part exists. So, a simple fix would
- 3:23be to use an if statement. If part then
- 3:26If the part exists, then we can set
- 3:28part.transparency
- 3:30to 0.5.
- 3:32else
- 3:34We can put a warning in the output using
- 3:36the warn keyword, something maybe like
- 3:39red part was not found.
- 3:42I'll remove this line now at the end.
- 3:44Now, when we run this, it says red part
- 3:46was not found.
- 3:48So, we've now turned that error that was
- 3:50breaking the code into something that's
- 3:52manageable, and this is just a log to
- 3:54let us know the red part was not found.
- 3:57So, now instead of crashing, the script
- 3:59safely checks if the object exists
- 4:01first. One of the easiest debugging
- 4:03tools ever is literally just print.
- 4:07For example, I can type in print
- 4:10script started.
- 4:12Now, when I press play, I get a debug
- 4:15log which says script started.
- 4:18Beginners often write huge scripts and
- 4:20have no idea where the problem is. So,
- 4:22instead, track what's happening. For
- 4:24example, let's print button clicked.
- 4:28And then we're going to set coins equal
- 4:29to 100.
- 4:31Now, let's print the number of coins we
- 4:32have.
- 4:33Let's add 50.
- 4:37And then let's print the coins again.
- 4:39Now, when we run this, we have button
- 4:41clicked 100, then 150.
- 4:44So, this lets you see
- 4:46did the code run, first of all?
- 4:49If button click is printing, then yes,
- 4:51the code has run.
- 4:53Did the value change? If the coins here
- 4:55is different to the coins here, we know
- 4:57that plus equals 50 has worked.
- 4:59And which part broke, if any?
- 5:02A pro tip I would give is to use warn,
- 5:04because warn is useful because it
- 5:06appears in yellow in the output window
- 5:09and is easier to spot. So, rather than
- 5:11printing coins and printing button
- 5:12clicked, I could warn button clicked. I
- 5:15could warn the coins, and I could warn
- 5:17the coins again. And now it's just a bit
- 5:19easier to spot in the output. I usually
- 5:22only use warnings if something genuinely
- 5:24has gone wrong in the code, and not for
- 5:26debugging, because a debug is only
- 5:29temporary. I'm only going to leave a
- 5:30temporary print in there if I'm
- 5:33debugging. I'm not going to leave it in
- 5:34there permanent. I just want to cover
- 5:36some of the most common beginner bugs.
- 5:39So, the most common bug that I see in
- 5:40our Discord server when people are
- 5:42asking for help and in the comments of
- 5:43videos, are misspelling names.
- 5:46This one gets everyone. Let me write
- 5:48some example code here. Let me add a
- 5:50part to the workspace.
- 5:52I'll just leave it named part and I want
- 5:54to change its brick color to bright red.
- 5:56I'm going to say
- 5:57workspace.part.brickcolor
- 6:01= brickcolor
- 6:05.new and I'm going to give it bright
- 6:08red.
- 6:10Let's run this.
- 6:12Part is not a valid member of workspace
- 6:14workspace. But let's look at the
- 6:16workspace. The part is a valid member of
- 6:18the workspace. So why am I getting this
- 6:20error? Well, the reason for this error
- 6:23we can see it's coming from the script
- 6:25named buggy code, which is this script
- 6:27here.
- 6:28And it's coming on line one. That's what
- 6:29the colon one means. So it's on line
- 6:32one.
- 6:33Let's have a look.
- 6:35What I can see here, I've misspelled
- 6:36part. In the workspace, it's p a r t and
- 6:40in here I've put p a r double t. So
- 6:42let's remove one of those t's. I'll just
- 6:43retype it.
- 6:45And let's run it again.
- 6:47I'm still getting the error. Part is not
- 6:49a valid member of workspace workspace.
- 6:51Quickly pause the video and see if you
- 6:53can spot what is causing this error.
- 6:56Hopefully you gave that a go.
- 6:58So, let's have a look.
- 7:01As we can see, it's spelled p a r t and
- 7:03I spelled it p a r t here. However, in
- 7:05the workspace, I have an upper case p
- 7:08and in the code, it's all lower case.
- 7:10The capitalization is very important. It
- 7:13must match exactly. So I need to have an
- 7:15upper case p and then all lower case a r
- 7:17t.
- 7:18And now if I run this, it will set the
- 7:20brick color to bright red.
- 7:22And there we can see that one letter has
- 7:24broken the entire thing.
- 7:26This next bug confuses beginners
- 7:28constantly and that is local scripts and
- 7:30scripts. Local scripts run on the
- 7:32player's computer. Normal scripts run on
- 7:35the server. I'm going to add to starter
- 7:38player scripts a local script.
- 7:41And I'm going to say
- 7:41game.players.playeradded
- 7:45colon connect
- 7:47function passing through the player that
- 7:48joined. I'll just print the player.name.
- 7:51So, usually in the server script, this
- 7:53code would run every time a player joins
- 7:55the server, and it would just print the
- 7:56name of the player. I'll put this local
- 7:58script in ServerScriptService.
- 8:01We can see no output runs.
- 8:04Now, let's put the local script where it
- 8:05should be in StarterPlayerScripts.
- 8:08And we still get no output. And that is
- 8:10because this is linked to the server.
- 8:12It's not something that runs on the
- 8:14player's machine. It runs on the server.
- 8:17So, this has to be in a server script.
- 8:19PlayerAdded won't work properly inside a
- 8:21local script like this.
- 8:23So, let's put it inside a normal script.
- 8:25I'm going to add a script to
- 8:26ServerScriptService named fixed script.
- 8:30And I'm just going to copy all the code
- 8:31and paste it into the fixed script.
- 8:35Now, when we run it,
- 8:37it prints out my username perfectly.
- 8:39I'll delete those two scripts now.
- 8:42Another one is infinite yields. So, this
- 8:45is a very, very easy one to
- 8:49notice, but sometimes it can be a bit
- 8:52hard to figure out why it's happening.
- 8:54You usually get this when you use
- 8:56WaitForChild. Let me write local part
- 8:59equals workspace colon WaitForChild. I'm
- 9:02going to wait for part.
- 9:05Now, I don't have a part in my
- 9:06workspace. Let's just run this and see
- 9:08what happens.
- 9:09At first, we don't get anything. After
- 9:12waiting a few seconds, we get something
- 9:14that says infinite yield possible on
- 9:17workspace colon WaitForChild part. If
- 9:20Roblox says infinite yield possible, it
- 9:22means the object is taking too long to
- 9:25appear. Usually,
- 9:27this means that the object name is
- 9:28wrong, it was deleted, or it's in the
- 9:31wrong location.
- 9:33To fix this, I'm just going to add part
- 9:35to my workspace. And now, nothing will
- 9:38output. I'll give it a few seconds and
- 9:41we won't get that infinite yield because
- 9:42it will successfully find that part now
- 9:45in the workspace.
- 9:47So, infinite yield just means
- 9:49double-check the object name. It might
- 9:51be spelled wrong, similar to what we had
- 9:53earlier in bug one.
- 9:56It was maybe deleted in runtime by
- 9:59another script or maybe it's in the
- 10:01wrong location. Maybe the part we're
- 10:03looking for isn't in the workspace, but
- 10:05maybe it's actually in the replicated
- 10:07storage. The fourth bug I see sometimes
- 10:10is variables not updating.
- 10:12Let me write some broken code here. I'm
- 10:14going to initialize a variable named
- 10:16zero. It's going to be a local variable,
- 10:18but it's local to the entire script, so
- 10:20it's effectively global.
- 10:22And I'm going to create a local function
- 10:24and I'll name this add coins. Inside of
- 10:27this function, I'll say local coins
- 10:29equals coins plus 10.
- 10:31This creates a new variable. Now, it's a
- 10:34bit harder to see what the problem is
- 10:35here. But, what is happening here is
- 10:37this is creating a new variable instead
- 10:40of updating the original. The fix would
- 10:43be to remove this local keyword in the
- 10:45function and just do coins equals coins
- 10:48plus 10.
- 10:49This changes the original variable
- 10:51correctly. When we use local in a
- 10:53function, it's creating a brand new
- 10:54variable to the original.
- 10:57Now, let me show you the actual process
- 10:59that most developers use. The first step
- 11:01is not to panic. If your game breaks,
- 11:03don't instantly rewrite everything.
- 11:06Read the error. That's step two. Read
- 11:08the error. Most beginners skip this
- 11:10completely. The output usually tells you
- 11:13what broke, where it broke, and
- 11:14sometimes why. Let's review one of those
- 11:17error messages from earlier. I'm going
- 11:19to force an error. I'm going to say part
- 11:22equals nil and then say
- 11:24part.transparency
- 11:25equals 0.5. I believe this was one of
- 11:28our examples earlier. Let's run this.
- 11:33So, the output tells you what broke. So,
- 11:36attempt to index nil with transparency,
- 11:38that's broken. Where it broke? Well, it
- 11:40broke Well, it broke in the script named
- 11:42buggy code on line three. You can also
- 11:44see that just here. It says server
- 11:46script and it broke on buggy code line
- 11:49three. So, we're going to look for that
- 11:51script, which is in server script
- 11:53service. So, in server script service,
- 11:55I've got a script named buggy code and
- 11:57on line three, I'm getting that error.
- 12:00And sometimes you why it broke. In our
- 12:02case, it says it's attempt to index nil.
- 12:04So, that tells me that we are trying to
- 12:06access the transparency property on
- 12:08part, but part is nil. So, part doesn't
- 12:11exist. That is step three as well, which
- 12:13is finding the exact line. So, line
- 12:16three.
- 12:16Step four is to test smaller pieces. For
- 12:19example, I could print before
- 12:22transparency, I could print the part
- 12:24just to make sure a part does exist. And
- 12:26then afterwards, I could print the part
- 12:28again just to check if part still exists
- 12:31after we change the transparency. In my
- 12:33case, I can see that it prints nil and
- 12:35then I get the error and the second
- 12:37print never prints because that error is
- 12:40preventing it on line five from ever
- 12:42reaching to line seven.
- 12:44So, I can see that it's breaking at line
- 12:46five, but my print part is allowing me
- 12:49to see that the part is actually nil.
- 12:51So, that's why I know that part is nil.
- 12:54I can tell it's wrong based on this
- 12:56print statement.
- 12:57A better example would be something like
- 12:59this. Let's print a statement before the
- 13:01function call and then print one after
- 13:03the function call. And if after function
- 13:06never prints, then you know the problem
- 13:08happened inside of open door. So, if I
- 13:11was to run this, after function never
- 13:13prints. So, we know the problem is
- 13:15inside of that function.
- 13:18In my case, the problem here is that
- 13:19I've not actually defined the function,
- 13:21so there is no code to run. The fifth
- 13:23step is just to change one thing at a
- 13:25time. Beginners often change 20 things
- 13:27at once, then they don't know what fixed
- 13:30the bug or what made it worse. Just fix
- 13:32one thing, test it. If it's still not
- 13:34working, fix another. If it is working,
- 13:36then happy days. You don't need to do
- 13:38much more.
- 13:39A lot of programming comes down to
- 13:40keeping a positive mindset, staying
- 13:42motivated and disciplined to actually
- 13:44get projects done. The number of
- 13:46projects I've started and never finished
- 13:48because I just thought, "Ah, I'm a bit
- 13:50bored now." Or, "Ah, that code's not
- 13:52working very well." And that's okay to
- 13:54have those drop-offs every now and then.
- 13:57But, the best developers stay
- 13:58consistent. They learn from their
- 14:00mistakes. And that is what programming
- 14:02is all about. It's all about
- 14:03problem-solving and going from A to B to
- 14:06C to D. Anyone that makes that jump from
- 14:08A to Z straight away, well, they're
- 14:10going to have 24 other letters that are
- 14:12going to be problematic. Whereas, if you
- 14:14focus on one letter at a time, one step
- 14:17at a time, you're going to get there in
- 14:19a much stronger way.
- 14:21So, if this video helped you, make sure
- 14:23to subscribe because we're uploading
- 14:25Roblox development videos every few
- 14:27days, as well as expanding to some new
- 14:29game engines. Comment below what the
- 14:31most confusing bug is that you've ever
- 14:33had in Roblox Studio.
- 14:35Also, join our Discord server, which you
- 14:37can find the link to in the description,
- 14:39because the over there you can actually
- 14:40post if you're having any problems with
- 14:42your games, if you're having any bugs.
- 14:45We've got a community of people, and
- 14:47we're trying to build that community.
- 14:49And we're all happy to help each other
- 14:51with our programming over there. You can
- 14:52also leave feedback on our videos, which
- 14:54is always highly recommended, and we
- 14:57really appreciate it. Thanks for
- 14:59watching, and I will see you in the next
- 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.