Cant Drop nodes because script does not inherit Node

Godot Version

4.7beta4

Question

imageso i got this error but i want to fix it but just does not want to work

and my script has a extends CharacterBody2D

. help will be appreciated :smiley:

Save your script, try again. If it still doesn’t work could you paste your code?

extends CharacterBody2D

var speed = 150.0

func _ready() -> void:
	add_to_group("asd")

func _physics_process(delta: float) -> void:
	var player = get_tree().get_first_node_in_group("player")
	var direction = global_position.direction_to(player.global_position)
	velocity = direction * speed
	if abs(direction.x) > abs(direction.y):
		if direction.x > 0:
			$AnimatedSprite2D.animation = "Right"
		else:
			$AnimatedSprite2D.animation = "Left"
	else:
		if direction.y > 0:
			$AnimatedSprite2D.animation = "Down"
		elif direction.y < 0:
			$AnimatedSprite2D.animation = "Up"
	move_and_slide()
func _on_area_2d_body_entered(body: Node2D) -> void:
	if body.is_in_group("asd"):

to bored to put names

for the groups

Check your scene. Its type has to match the script’s type.

Pro tip: when naming scripts do not give them the name of an existing class.

Change the name of the file you put your script in and the error will go away.