Godot 4 Multiplayer: Make Your Own Online Game

I am not sure what I am missing here.

Whatever this error is, I was not able to save my progress.


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 think it is at the top.

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.

  • Invalid
  • get index
  • ‘0’
  • on an array belonging to a Node2D (your level_01 object)

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.

1 Like

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.

1 Like

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!

Got it! (I think)

1 Like

Privacy & Terms