Can't export vars in 4.0

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

Hello, when I try to export a var in 4.0 with the syntax

export(float) var velocity

export(NodePath) var target_node_1

I get the error

Unexpected “Identifier” in class body.

full class code

extends KinematicBody3D

export(float) var velocity
export(NodePath) var target_node_1

func _ready():
pass

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

:bust_in_silhouette: Reply From: omggomb

In 4.0 you need to use annotations combined with typing:

@export
var velocity: float

@export
var target_node_1: NodePath 

See the docs on annotations and exports for more info:

Notice that you need to look at the docs for “latest” instead of “3.2” down in the bottom left of the docs.