How to change scene by player points? What's wrong with my code?

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

What is wrong with this code? When player gets points I want scene change to next level. extends Node2D

var points = 0
var x = 1
var y = 1
var z = 1

func _ready():
pass # Replace with function body.

func changelevel():
var points = x + y + z
if points > 2:

:bust_in_silhouette: Reply From: rustyStriker

honestly, not much can be said with the almost non existing info you provided…

  • gettree() should be called as get_tree()
  • check if you ever call changelevel() function
  • you are “shadowing” an already existing variable which is not allowed in godot(i think)