Help needed to change levels for a space shooter

Question

Hi, I’m a complete beginner at game development and using Godot so for my first project I decided to create a 2D space shooter. I want to include levels that would be completed when a certain score is achieved , how could I do this? Any help is appreciated.

it looks like a level is just about target_score, and how many enemy is spawned per level?
then a level will just need to store those 2 values. the values of each level can be stored in JSON text and be read as leveling data.
from those 2 values in a level. the game with its main script actually create the target score and spawn X number of enemy. when player achieved the target score, next level is loaded from stored Variable of JSON data just now.

So the game main script should keep track what level the player is currently now, and just load the level when requested. the levels data should be already loaded from JSON text to Variable when the game first run

Thank you for help. Yes a level is about a target score, I currently have a score counter but nothing else. I never heard of JSON text before, do you know of any tutorials on how to use it or do you have any other advice on how to change the levels.

there’s always a documentation for something like this:

what really matters is the parse_string method

var data = JSON.parse_string(json_string)

JSON file can be created by notepad even and save as .json. it’s organized in such a way that it looks like and array with dictionary/another array inside it. depending how you want to structure your level data
as for now since it’s just target score, the json file should like this:

[
   {
      "level":1,
      "target_score":100
   },
   {
      "level":2,
      "target_score":120
   },
   {
      "level":3,
      "target_score":150
   },
   {
      "level":4,
      "target_score":200
   }
]

put this as json file from notepad and save it as leveling_data.json
then throw it into your godot game as an asset
then you can load the JSON text file by

var leveling_file = FileAccess.open("res://leveling_data.json", FileAccess.READ)
var leveling_text = leveling_file.get_as_text()
var data = JSON.parse_string(leveling_text)

That’s great, thank you for your help