Infinite loop errors in map - best troubleshooting practices?

Thought it might be easier to just paste whole code to seach and in case of follow up questions.

This is the move loop:

 MoveTheDragon(FC:fort_character)<suspends>:void =
        MoveLimitSq := 2048.0 * 2048.0
        loop:
            Print("Dragon movement L00P")
            Sleep(0.1)
            if(IsActive?):
                SaddlePos := TamableDragon.GetTransform().Translation
                PlayerRot := FC.GetViewRotation()
                var MoveVector : vector3 = vector3{X:=0.0, Y:=0.0, Z:=0.0}
                
                # Calculate forward, right, and up vectors from the player's rotation
                # Calculate forward and right vectors from the player's rotation
                ForwardVector := PlayerRot.GetLocalForward()
                RightVector := vector3{
                    X := ForwardVector.Y,
                    Y := -ForwardVector.X,
                    Z := 0.0
                }

                # Up vector, which points upwards in the Z direction
                UpVector := vector3{
                    X := 0.0,
                    Y := 0.0,
                    Z := 1.0
                } 

                # Down vector, which points downwards in the Z direction
                DownVector := vector3{
                    X := 0.0,
                    Y := 0.0,
                    Z := -1.0
                } 
    
                if(MovingForward?):
                    PitchedRotation := PlayerRot.ApplyPitch(32.0)
                    set MoveVector = PitchedRotation.GetLocalForward() * 512.0
                
                if(MovingBack?):
                    set MoveVector = MoveVector + ForwardVector * -256.0
                
                if(MovingLeft?):
                    set MoveVector = MoveVector + RightVector * 384.0
                
                if(MovingRight?):
                    set MoveVector = MoveVector + RightVector * -384.0

                if(MovingUp?):
                    set MoveVector = MoveVector + UpVector * 384.0
    
                if(MovingDown?):
                    set MoveVector = MoveVector + UpVector * -384.0
        
    
                var MovePos : vector3 = SaddlePos + MoveVector
    
                var PathClear: logic = true
                if(A := MaybeOwnerAgent?):
                    DragonForwardPos := SaddlePos - vector3{X:=0.0, Y:=0.0, Z:=500.0}
                    MaybeHitLoc := MorituriRaycastDevice.RayCastForAgent(A, transform{Translation:=DragonForwardPos, Rotation:=PlayerRot, Scale:=vector3{X:=1.0, Y:=1.0, Z:=1.0}})
                    if(HitLoc := MaybeHitLoc?):
                        set MaybeFireballHitsPosition = option{HitLoc}
                        DistSq := DistanceSquared(HitLoc, SaddlePos)
                        if(DistSq < MoveLimitSq): 
                            set PathClear = false
                    else:
                        set MaybeFireballHitsPosition = false
    
                if(PathClear?):
                    spawn{TamableDragon.MoveTo(MovePos, PlayerRot, Speed)}
    
                if(A := MaybeOwnerAgent?):
                    FireballStartT := FirebreathRoot_Prop.GetTransform()
                    FireballForward := FireballStartT.Rotation.GetLocalForward()
                    FireballStart := FireballStartT.Translation + FireballForward * 500.0 + vector3{X:=0.0, Y:=0.0, Z:=200.0}
                    set MaybeFireballHitsPosition = MorituriRaycastDevice.RayCastForAgent(A, transform{Translation:=FireballStart, Rotation:=FireballStartT.Rotation, Scale:=vector3{X:=1.0, Y:=1.0, Z:=1.0}})
                
                if(P := MaybeFirebreathVFX?):
                    var T : transform = FirebreathDamageZone.GetTransform()
                    spawn{P.MoveTo(T, Speed)}
    
            else if(not IsActive?):
                break