gamemode spectator @s

execute as @s[tag=!25.end1] at @s run summon armor_stand ~ ~0.4 ~ {Invisible:1b,Tags:["armor_stand_25"],Motion:[0.0,0.6,-1.0]}

spectate @e[type=minecraft:armor_stand,tag=armor_stand_25,sort=nearest,limit=1,distance=..1.5] @s

execute as @e[type=minecraft:armor_stand,tag=armor_stand_25,distance=..1,nbt=!{Motion:[0.0d,-0.0784000015258789d,0.0d]}] at @s run tag @p remove 1

execute as @s[tag=1] at @s run execute as @e[type=minecraft:armor_stand,tag=armor_stand_25,distance=..1,nbt={Motion:[0.0d,-0.0784000015258789d,0.0d]}] at @s run gamemode adventure @a[sort=nearest,limit=1,tag=25.end]

tag @s add 25.end1

tag @s[tag=1] remove 25.end1
tag @s[tag=1] remove 25.end

execute as @s[tag=1] at @s run execute as @e[type=minecraft:armor_stand,tag=armor_stand_25,distance=..1,nbt={Motion:[0.0d,-0.0784000015258789d,0.0d]}] at @s run kill @s
tag @s[tag=1] remove 1

execute as @e[type=minecraft:armor_stand,tag=armor_stand_25,distance=..1,nbt={Motion:[0.0d,-0.0784000015258789d,0.0d]}] at @s run tag @p add 1