A Tween is a little animation that is created in code.
We will make one to add a visual enhancement to the coin pickup
Update the pickup function
While Godot is in the middle of calculating physics or processing collisions, the physics engine locks down certain properties—especially collision shapes. Changing them directly during an active collision check can cause crashes or trigger a "Function blocked during in/out signal" error.
set_deferred(property, value) tells Godot:
"Don't change this property right this millisecond—wait until the current frame's physics step finishes, then safely apply the change."
Whenever you need to turn off a CollisionShape2D or Area2D inside a collision callback like _on_area_entered(), always use set_deferred("disabled", true) instead of .disabled = true.
set_deferred() prevents the player from accidentally triggering the same coin twice while it's playing its pickup animation.
set_parallel() tells the Tween to run all following animations together.
TRANS_QUAD applies smooth acceleration or deceleration (like a car easing into motion) to make the juice/effect look polished.
The first tween_property Expands the coin to 3 times its size over 0.3 seconds.
The second tween_property Fades the coin out until it's completely invisible over 0.3 seconds.
await Pauses this script until the animation is done.