It’s a natural part of being a coder: we build something with great expectations, only to find that it doesn’t work 💫. And what’s worse: we can’t see what the problem is! Don’t worry though, because this is a constant issue for pretty much every coder who ever coded. Of course we’re always happy to take a look at your code, but we like to encourage people fixing their code themselves first, as we think this makes for better programmers! 😁
Here are some of our top tips for debugging your code so you can get back to the fun.
Checking With Lara 👩
Watch the videos again to see how Lara writes the code. Sometimes the code can be tricky and checking it over often solves the problem. You can use the hints to see what code changes are expected. If you’re really stuck, there is a skip button you can use. It is set to the current step and will set the code to exactly what it is within the video. The following guide can help debug some of these problems:
Tick Off the Chapter
Code differences can sometimes mean that your code won’t run correctly. The chapter will only tick off if everything has been completed the same as the video, so if the editor says you’re still on a previous chapter, click the hint button to check and see what you need to add or change to complete it 😎
Minor Differences
Sometimes the steps don’t tick off if there are minor differences that don’t affect the behaviour of the code - for example, spelling or punctuation differences when naming variables. We’re working to resolve these so the steps always tick off correctly - check out the hints to see if there’s anything you need to change.
Print Statements 💬
In Roblox, adding print statements in the code to check if it is running well is very useful. You can add a print statement above the code you are expecting to run - for example it may make sense to add a print statement above a zombie:Clone method if your zombies aren't spawning, to check that is actually running. In Minecraft, you can do much the same thing with sendMessage methods!
Read Your Error Messages
Getting any error messages in your project? Don't panic - the code editor will tell you which file is to blame, and can highlight lines that might be wrong. Make sure you check the file very carefully for anything that might be different to the video. Read the error message carefully - it'll usually be able to tell you what exactly is wrong (for instance, using the wrong type in a function).
If you don't understand your error messages at all and you're completely stuck, do send it over to us as a screenshot and we can help you work out what's up 😀