Why is it null?

Godot Version

4

Question

how do i implement it???

	await get_tree().process_frame

full script:

extends Control 

@onready var _dialogue : Label = $Texty
var _typing_speed : float = 30
var _typing_time : float

func _ready():
	display_text("Excuse, me Maam... I noticed someone was 
	following you through the store. 
	I just wanted to let you know in case
	you didnt know him.")
	
func display_text(text : String):
	_dialogue.text = text
	_dialogue.visible_characters = 0
	_typing_time = 0
	while _dialogue.visible_characters < _dialogue.get_total_character_count():
		_typing_time += get_process_delta_time()
		_dialogue.visible_characters = _typing_speed * _typing_time as int
		await get_tree().process_frame



func _on_retryyay_pressed() -> void:
	get_tree().change_scene_to_file("res://level3.tscn")
	World.current_level = 3

func _on_nextwow_pressed() -> void:
	get_tree().change_scene_to_file("res://thats it.tscn")
	

Seems like you’ve made this thread before here.

Can you confirm or deny any of these conditions? How is this script being added to the scene? And how is it being removed?

yeah sorry… I just dont know what it is becasue when i fixed the quotations and $Texty before it worked then it just suddenly stopped working

Right, but there is more to this issue than random chance.

When you remove this node from the tree it will fail to get_tree(), so if your while loop for displaying visible characters is interrupted you will have an error. How could you modify your while loop to also check if get_tree() is valid, or if the node is_queued_for_deletion()?

You better replace this part to

await RenderingServer.frame_post_draw

it will access global singleton which is available form any class and ensures visual frame was changed (noticeable frame change)