+1 vote

Hello Godoters,
I have just started making a text game.I'm learning from one guy on youtube (here is the link https://www.youtube.com/watch?v=5gP1eOtR5Kg) and here is the code:
extends Control

const InputResponse = preload("res://InputResponse.tscn")

onready var history_rows = $"Background/MarginContainer/Rows/GameInfo/ScrollContainer/HistoryRow"

func onInputtextentered(newtext: String) -> void:
var input
response = InputResponse.instance()
historyrows.addchild(input_response)

I came to the point where I have to add a scroll bar into my game.
I have followed all his instructions but it doesn't work.The engine keeps showing attempt to call function error 'add_child' in base 'null instance' on null instance.

Godot version v3.2.2.stable.official
in Engine by (18 points)

1 Answer

0 votes

"null instance" is what you get when you get_node() something that doesn't exist. Since you're calling add_child() on history_rows, that means that

$"Background/MarginContainer/Rows/GameInfo/ScrollContainer/HistoryRow"

is an invalid path.

by (20,481 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.