Stair climbing animation does not work correctly

Godot Version

Godot Version 4.3

Question

Hello everyone!

I am developing a fear of heights simulation in which the main object is a big tower which should be climbed by the player.
I have the following code section which should check if my player steps on a stair or is on the floor outside the tower or on a floor of an intermediate floor inside my tower.

if not is_player_collided:
transform3d.origin += motion
motion = -step_height
test_motion_params.from = transform3d
test_motion_params.motion = motion
#animationplayer.play(“Armature|mixamo_com|Layer0”)
is_player_collided = PhysicsServer3D.body_test_motion(self.get_rid(), test_motion_params, test_motion_result)
print(“2.Bedingung”)

				if is_player_collided:
					var collider = test_motion_result.get_collider()
					print("Kollisionsobjekt:", collider)
					print("Bedingung 2.5")
					if collider is Node:
						if collider == $"../Boden/StaticBody3D" || collider == tower.get_node("Würfel_900/Boden Etage 1"):
							print("Gehen")
							animationplayer.play("Armature|mixamo_com|Layer0")
							print("Gehen abgespielt")
						elif collider == tower_collider:
							print("Turmkollision")
							animationplayer.play("Armature_001|mixamo_com|Layer0")
						else:
							print("Was anderes")
					#if test_motion_result.get_collision_normal().angle_to(Vector3.UP) <= 2:
					is_step = true
					step_result.is_step_up = true
					print("3.Bedingung")
					step_result.diff_position = -test_motion_result.get_remainder()
					step_result.normal = test_motion_result.get_collision_normal()
					print("Oder")
					break

Depending on where the player is, either a normal walking animation or an animation for climbing stairs should be played. Everything works with the walking animation. The player also enters the condition for the stair climbing animation, but here the player is initially only moved to the start position of the animation (the first keyframe) as long as the upper arrow key (ui_up) on the keyboard is still pressed. The stair climbing animation is only played as soon as the button is released. As a test, I have also called the stair climbing animation in the first condition, as everything is played correctly in the walking animation. But here too, the stair climbing animation is only played after the button is released. Does anyone have any idea why this might be? The print-instructions are only for debugging.

If you need more information, please let me know!
I would be very thankful for some help!

Kind regards!