Unexpected '“Identifier” in class body using Rigidbody2D

Hello, I use the 4.3 version of Godot and i’m a complete beginner at programming. I’m making a 2D platformer game for a school project and I’m a bit lost with scripting since I only followed tutorials or asked AI for help.

Question
Why do I get a red error saying : Unexpected '“Identifier” in class body along with a yellow error saying : the parameter “area” is never used in the function “_on_area_2d_area_entered()” on the first line of my script.
Here is my script:

extends RigidBody2D
export var speed = 100
var velocity = Vector2()
func _physics_process(delta):
var player = get_parent().get_node(“player”)

velocity = position.direction_to(player.poition) * speed
velocity = move_and_slide(velocity)
look_at(player.position)

you probably didnt “indent” your code? I can only guess since you didnt format your code correctly here. Does the red error give a line-number?

I don’t know how to format my code correctly, I only copy and pasted it here. Maybe an image could help
Picture of the script
as you can see in the picture the red error is at (1,20)

You are using the Godot 3 syntax. It’s @export in Godot 4, not export. And your code would become more readable if you add a blank line after extends RigidBody2D.

2 Likes

Thank you very much !!! :>