Pressing F1 will pull up a help search in Godot, you can read the docs on Node or Node2D to learn what properties it has. You could search for “shake” but nothing has that property, i suspect you mean to use “current_shake” as that variable is in your script.
Do you even need tweens?
You already have all the info you need. Is this what you’re going for?
I changed the amount to 5 so it’s more noticeable and so that when you press the space bar you start shaking the image.
If this is what you need, without the need for tweens, here’s the code:
class_name ShakeComponent
extends Node2D
var current_shake = 0
@export var sprite: Node2D
@export var shake_amount: = 5.0
@export var shake_duration: = 1
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("ui_accept") and current_shake == 0:
current_shake = shake_amount
current_shake -= shake_amount * delta / shake_duration
if current_shake < 0:
current_shake = 0
sprite.position = Vector2(randf_range(-current_shake, current_shake), randf_range(-current_shake, current_shake))