I am not sure what I am missing here.
Whatever this error is, I was not able to save my progress.
Hi,
Where is the spawn_points variable declared, is it at top of script somewhere?
Normally that error, when Iâve seen it in the past, is that itâs trying to save the scene/script if the game is still running in the background and not stopped in the editor.
Iâm pretty sure OboShape is right about the project still running. âUnable to write fileâ usually means the file is in use.
Now that we can see where you declared the variable, your original error is because you declared it as _spawn_points
instead of spawn_points
(leading underscore). When you see ânot declared in the current scope,â the first thing you should look for is a typo in your variable name, because 99% of the time, thatâs what causes that particular error =)
Perfect! Thank you!
One day I will spot it without help. LOL
I fixed one error on my own.
I got another one. I tried this new one and cannot figure this one out.
This error happens after I START to play game.
Making progress then! Ok.
means the array has no value at that index - the program tried to return something that doesnât exist (I broke that down into bullets because thatâs how you go about reading an error statement. You wonât always be able to understand these errors because occasionally theyâre downright cryptic, but this approach helps a lot).
If this is happening on index 0, it usually means the array is empty unless you have a good reason to skip indeces when giving it values. Whenever an array is unexpectedly empty, understandably you should check anywhere the array is being populated with data. Since spawn_points
is an export variable, you should also check the inspector of this node to see if the field has been filled properly (and it may very well not be, as you renamed this variable by removing the leading underscore).
Invalid get index is a very common error, and itâs almost certainly going to be caused by one of these two things. Let us know what you find.
Thank you.
Not quite sure I am following fully. I am sort of getting it.
I just checked and I donât know where to make the edit.
Well, the error is resulting from trying to get the value of the array spawn_points
at array index 0, which is at the beginning of the array. It canât get that value because itâs discovering that it doesnât exist - thereâs no value there to get, and this is because you are expecting the array to have some data in it, but it doesnât for whatever reason. Therefore the program throws an error.
It might be that you canât find anything because youâre only looking in the level_01
script, but remember that spawn_points
is an export variable, so the data it gets filled with is coming from somewhere else. In addition to level_01
, check wherever spawn_points
is coming from, and also double-check that the field is filled (because if itâs empty, thatâs your problem).
If youâre completely at a loss, try Ctrl + Shift + F and search for spawn_points
(this feature is called âFind In Filesâ btw, and itâs very useful). This will show you every place it appears across ALL your scripts.
Thank you for your help! I used the search and found the spawn_points. Just need to figure out how to make the change. I will watch the video again.
The instructor typed in 0.
Since Find In Files searches through all scripts, and none of the results indicate that there is code setting spawn_points
to some value, and we can see that spawn_points
is an @export
variable, this can only mean that values are entered directly in the inspector (unless of course those values come directly from another array like the Polygon in Kaanâs Speedy Saucer game, which I donât think is going to be the case here). I would indeed see if you can find the video where spawn_points
is given values.
Edit: Spawning Players, 12:30 to the end. This is where spawn_points
is populated, so by all means watch it again. Thatâs the nice thing about video courses - you can watch and rewatch as much as you need to.
OK. I will definitely watch it again.
Thank you!
Hi. New issue.
When I paly the game to test it, the player steps on plate and the game shuts down or stops and the script window with error is shown.
Another thing I noticed in the Replication window, the instructor has different options. I donât have. Not sure if that is causing any issues for me.
I made the correction the instructor mentions later in the same lecture. I synched the MultiplayerSynchronizer to the Delta Synchronizer.
Any time you see an error message, I would recommend that the first thing you do is read it very closely. Skimming is not enough; look at it word by word with a figurative microscope. The reason for that is, sometimes thatâs all you need to do.
Do that with this one. Can you spot the issue? I will tell you if not, so donât panic, but this is good practice =)
I canât help with the other part unfortunately, but I suspect itâs a similar issue to your missing @export
variables a few weeks ago, so all I can suggest is to watch the lectures again and look for anything you might have missed.
Hi, I appreciate the challenge. I am going to give it a shot now.
Thank you!
A typing error again. OMG!
It works now. Thank you!
I am trying like heck! Maybe I am trying too hard. SMH
Remember when you said âSomeday Iâll find it without helpâ?
Looks like âSomedayâ came.
Personally, I think itâs less that youâre trying too hard and more that you would benefit from boosting some foundational skills.
Coding is one thing, but navigating your way through the inevitable bugs and errors that come from coding is a whole different beast. Even when I was taking programming courses in school, very few other students actually had a solid grasp of debugging strategies, and thatâs because there was comparatively almost no instruction in it at all (not the professorsâ faults, but thatâs another matter).
This is a pretty good start (not all of the article is relevant; I recommend reading from âHow to Debug your Codeâ to down to âWrite simple code when possibleâ). Check this out when you get a chance, and then, the next time you run into a problem, read through this again and try some of whatâs in there:
Yes, I certainly did. Thank you! I understand what you mean.
Thank you for the resource!