0 votes

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:
gettree().changescene("res://Level_2.tscn")

in Engine by (12 points)

1 Answer

0 votes

honestly, not much can be said with the almost non existing info you provided..
BUT:

  • 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)
by (1,193 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.