![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | MrGenie151 |
I’m trying to add a dialog box to my game, and I’m having trouble implementing it so I can use it with my sign. What should I do?
It keeps spitting this error at me: Invalid set index ‘dialog’ (on base: ‘PackedScene’) with value of type ‘Array’.
This is my code:
extends Area2D
export(Array, String, MULTILINE) var dialog
export(float) var textSpeed = 0.05
var canInteract = false
const dialogBox = preload("res://Assets/Objects/DialogBox.tscn")
func body_entered(body):
if body.name == "Player":
canInteract = true
func body_exited(body):
if body.name == "Player":
canInteract = false
func _ready():
connect("body_entered",self,"body_entered")
connect("body_exited",self,"body_exited")
dialogBox.dialog = dialog
dialogBox.textSpeed = textSpeed
func _input(event):
if Input.is_action_pressed("interact") and canInteract == true:
canInteract = false
var dialogInstance = dialogBox.instance()
get_parent().add_child(dialogInstance)