Godot Version
4.6.1
Question
so im trying to make a cutscene system for my game since i dont want to make a different script for every cutscene, i thought itd be smart to, when the animation is done, have a label, set its text to the path of whatever scene i wanna switch to and just switch to that scene, but it isnt working
this is my code:
extends Node3D
var nextscene = $SceneName.text
func _ready():
$AnimationPlayer.play("cutscene")
nextscene = $SceneName.text
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
get_tree().change_scene_to_file(nextscene)
(the label is called SceneName, its text in this situation is “res://Assets/Scenes/MainMenu.tscn” which is the path to the main menu scene)
can anybody help me??? it does detect when the animation finishes but it doesnt switch scene
these are the 2 errors i get:

thanks in advance!!!