Next time you ask a question, it would be helpful to post what specific errors you're getting.
So I see a bunch of errors here:
get_sprite_frames(0).get_frame_count("Attackanimation")
Area2D does not have the method get_sprite_frames()
- it's for AnimatedSprite and takes no arguments since it's an accessor method. If attacksprite
is the AnimatedSprite you need
attacksprite.frames.get_frame_count("Attackanimation")
Also, if attacksprite
is the first child of the Area2D, there is no need to have get_child(0)
when you already have a variable that points to that node. Also, set_frames()
isn't a method. You're probably looking for set_sprite_frames()
, but you can just set the frames
property directly since there are no private properties in GDScript. It doesn't take an int
as an argument but rather a SpriteFrames
resource, which I'm guessing is the frames
variable.
I suggest that you read some more tutorials on GDScript so you understand how methods and variables work.