Invalid get index 'show' (on base: 'null instance')

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CREEPERCodingStudios

First, wow, it is annoying that half the programming software out there doesn’t have error messages that makes sense. Anyway, I got this message in this game file: Dropbox - File Deleted - Simplify your life I really don’t know a way of explaining it without showing the game files, so here you go. Thanks for your help in advance!

I’ll see it in a moment and see if i can help.

p7f | 2019-01-11 11:44

:bust_in_silhouette: Reply From: p7f

Hi,
I’ve seen two main problems. The first is in line 19 of RichTextLabel.gd.
There you are trying to use show() function from RichTextLabel node. However (besides you forgot the () in show), as the script is attached directly to RichTextLabel, you shouldn’t try to get this:

get_tree().get_root().get_node("Polygon2D/RichTextLabel").show

but call directly to show:

show()

or if you want to use full path:

get_tree().get_root().get_node("Node2D/Polygon2D/RichTextLabel").show()

The error isn’t to hard to interpret once you start to know the engine a little. It says Invalid get index 'show' (on base: 'null instance') because the sentence get_tree().get_root().get_node("Polygon2D/RichTextLabel").show returns null as you are trying to get RichTextLabel from that full path, and you are missing Node2D. So the error says that the null returned has not an index called show.

Similar error is the one you have in the timer timeout’s function. There you use:

$RichTextLabel.show()

but you are already inside RichTextLabel as the script is attached to it. So instead you should directly use:

show()

The other things i see are that the text won’t show anyways, because it’s Polygon2D is not visible, and also you set to 0 visible characters in ready. You need to change that when you want the text to appear, but i assume you already know that.
Tell me if its helps! it works on my pc

Hey, thanks again! By the way, I didn’t mean for the text to show up yet, so that’s not an issue, but yeah. I’ll try to keep this in mind so this error doesn’t happen again.

CREEPERCodingStudios | 2019-01-11 23:12

Er, while you’re here. What’s the reason why when I say hide()…it doesn’t?

CREEPERCodingStudios | 2019-01-11 23:17

I’ll check when i get home… in which line is the hide that is not working?

p7f | 2019-01-11 23:56

Eerrmm, actually, never mind. I got it. But I do have another problem. (Oh, yeah. I’m a problem factory) Don’t worry. I’ll stop bothering you after this: what’s wrong with this code?

func _input(event):
if event.type == InputEvent.MOUSE_BUTTON && event.is_pressed():
if get_visible_characters() > get_total_character_count():
if page < dialog.size()-1:
page += 1
set_bbcode(dialog[page])
set_visible_characters(0)

It has the same error message as before, but with ‘type’ instead of ‘show’ and ‘InputEventMouseMotion’ instead of ‘null instance’

CREEPERCodingStudios | 2019-01-12 00:50

In on my phone right know so i cannot test what im going to tell you. But i think that in godot 3 you should use:

if (event is InputEventMouseButton):

Instead of

if (event.type == InputEvent.MOUSE_BUTTON):

Please tell me if this works for you!
Anyway, just for the record, is better that if you have different questions you ask them on different questions, so more people can answer you and you get more chance of a faster answer! And if remember to select the answer that best worked for you so others with similar problems can easily find the answer.

p7f | 2019-01-12 01:15

Okay! Thanks for the tip. I’ll try this now.

CREEPERCodingStudios | 2019-01-12 01:20

Yay, it works! Thanks…for the 5th time? 6th? I dunno.

CREEPERCodingStudios | 2019-01-12 01:23

You are welcome! You may select the answer if it helped!

p7f | 2019-01-12 01:34

would you select my answer?

p7f | 2019-01-14 13:15

:bust_in_silhouette: Reply From: cymrix

Not sure if this is relative, but this is one of the top results when searching “godot invalid get index on base null instance”.

After much trial and error, I found that the child nodes of my root node are not accessible until the “ready” function. If I tried to reference them at the top of the script or in the “init” function, I just kept getting “null”.

Maybe this is common knowledge for experienced godot people, or it’s listed somewhere I haven’t seen yet, but it really made my life difficult for two days.