Im trying to make a dialogue but the game crashes

Godot Version

4.3

Question

im making a 2D pixelart platformer and i was trying to make an npc with a dialogue.the npc scene went fine but the dialouge not.there is an error at E 0:00:00:0757 DialougePlayer.gd:19 @ load_dialouge(): Parse JSON.Error at line 2: Expected ‘,’ but i dont understand what’s wrong with it.btw here is my code from the dialogue scene:

extends Control

@export_file(“*.json”) var d_file

var dialogue =
var current_dialouge_id = 0

Called when the node enters the scene tree for the first time.

func _ready() → void:
start()

func start():
dialogue = load_dialouge()
current_dialouge_id = -1
next_script()

func load_dialouge():
var file = FileAccess.open(“res://assets/dialouges/first_text.json”, FileAccess.READ)
var content = JSON.parse_string(file.get_as_text())
return content

func _input(event: InputEvent) → void:
if event.is_action_pressed(“ui_accept”):
next_script()

func next_script():
current_dialouge_id += 1
if current_dialouge_id >= len(dialogue):
return

$NinePatchRect/Name.text = dialogue[current_dialouge_id]['Name']
$NinePatchRect/Name.text = dialogue[current_dialouge_id]['Text']

That’s means your JSON file is wrongly formated, you need to check the contents and find what’s wrong.

1 Like

Thank you a lot! i really appreciate it!on my Json file the second text was always failed with no reason so i ignored it but now i just deleted all texts exept the first one.

oh also i was able to put the texts back by puting comas"," after the quotes"{}"thanks for the tip now im more motivated for my game

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.