I am trying to code a timer start after another timer times out. However, the game breaks down and I get a warning that I cannot call method start on a null value. I have tried erasing its onready variable and the start code and rewriting it, but is still persists. Just so you know, this is in a scene with three timers in it, each set to one shot (I think this means it will only run once in the scene).

If anyone who knows how to code sees this, please try to fix it for the next Godot version. I don't know how to code that well, and I don't know the language Godot was coded in. Thanks!

    Try showing is the code where you start the second timer?

    ArDanZ11 why do you need 3 timers? why cant you restart the same timer with new time limit?

    The error says exactly what you need to know, you are trying to set something to a null value. Meaning the timer does not exist. You need to create it, add it to scene tree or something.

    ArDanZ11 I don't see how this is a Godot bug. Sounds like something easily doable yourself, but you need to explain your problem better and show some code and what you are trying to do (and why).

    • Edited

    ArDanZ11 It's more likely that the bug is in your code, not in Godot's code. But we can't be sure until you show your code.

      xyz It's more likely that the bug is in your code

      Yes. I've used Timers extensively, both in Godot 3 and Godot 4, and they work very well.

      ArDanZ11 If anyone who knows how to code sees this, please try to fix it for the next Godot version.

      If you actually found a bug, reporting it here is not useful. Bugs should be reported at https://github.com/godotengine/godot/issues

      Here is the code for the scene:

      extends Control
      @onready var story_label_1: Label = $StoryLabel1
      @onready var story_label_2: Label = $StoryLabel2
      @onready var conclusion: Label = $Conclusion
      @onready var story_label_1_timer: Timer = $StoryLabel1Timer
      @onready var story_label_2_timer: Timer = $StoryLabel2Timer
      @onready var conclusion_timer: Timer = $ConclusionTimer
      @onready var music: AudioStreamPlayer = $Music
      
      
      # Called when the node enters the scene tree for the first time.
      func _ready() -> void:
      	story_label_2.hide()
      	conclusion.hide()
      	story_label_1_timer.start()
      	music.play()
      # Called every frame. 'delta' is the elapsed time since the previous frame.
      func _process(delta: float) -> void:
      	pass
      
      
      func _on_story_label_1_timer_timeout() -> void:
      	story_label_1.hide()
      	story_label_2.show()
      	conclusion.hide()
      	story_label_2_timer.start()
      
      
      func _on_story_label_2_timer_timeout() -> void:
      	story_label_1.hide()
      	story_label_2.hide()
      	conclusion.show()
      	conclusion_timer.start()
      
      
      func _on_conclusion_timer_timeout() -> void:
      	get_tree().change_scene_to_file("res://Levels/One/Level_1.tscn")

      I don't know if that is a bug. I was trying to create a story for my top down RPG game I'm making. The reason I posted here was because I thought there would be an easy way to work around this that I didn't know. I am pretty sure that this is a bug, because it was calling my timer statement variable a null value, even after I re-stated it, and re-wrote the code that started it. If this is a bug, I will report it, and work around it. Also, I don't think I'm using the latest version of Godot.

      • xyz replied to this.
        • Edited

        ArDanZ11 Unlikely an engine bug. You probably have some mess up in your scene/node setup.

        Post the scene structure and the exact error message. Also, debugging 101; put print statements in your signal handlers to see when and in what order they get called.

        This type of thing is better handled with animation players or tweens, rather than timers.

          xyz I did it!

          I restarted my computer without changing anything since I last had the problem and it worked.

          I really don't know what the problem was, but restarting it really helped.

            ArDanZ11 recompiled correctly. Sometimes godot does that, it loses references to some objects. Saving scene/script and or rebooting, deleting project .godot directory helps sometimes..

            Engine is not perfect, it will have bugs..

            8 days later

            Restarting my computer usually fixes the problem... usually...