Sometimes, when you get done writing a script for Roblox, it doesn't work the way you want it to. Here is how to figure out why your Script is not working.
First, you will want to make sure you can see the output window. To open the output Window first go to the View tab and then select output if it is not already selected.
Now that you can see the output screen, go ahead and run your game. Depending on what the issue is, an error might be visible right away or after you interact with a part attached to a script in your course. Regardless of when it appears, it will be in your output window and will look like this:
Now, take a look at the issue to see what is wrong:
The Red text tells us What the error is,
While the Blue text tells us Where the error is.
If you click on the Blue line, then it will open the script and put your cursor on the line with the error.
Now we can look at the line with the error and the red line that says what the error is.
So in this case it is saying that hitbox is not a valid member of Model. So What we do is we check our explorer where our script is located.
Now if we follow the line of code we can see what went wrong. In the line we start off with the script (1 in red above) then we go to script.parent which is the model named Treasure (2 in blue above) then we are supposed to go to Hitbox, but it is saying Hitbox does not exist.
The issue in this case is the spelling. In the code we have
where we put hitbox with a lowercase h, but in the explorer we have
Hitbox with a capital H. So to fix the issue we change the h in the code to a capital.
Now we can run the game again and see if the error has gone away.
Important to know:
The file paths are what cause the biggest issue. When you are checking for an error that you may have follow what we did above. Follow the line of code that has the error and check each individual parts location in the explorer, making sure that the order and the spelling matches that in the explorer exactly.
Still not working?
If you still can not solve the issue after trying everything above, click the button below to see how to send us your RBLX and we will be happy to help.
Please sign in to leave a comment.