My AI pet jumps infinitely randomly

I have a pet AI script (Which is still unfinished) made from scratch, here is a small important part from the code:

		for _, waypoint in pairs(waypoints) do
			if AlreadyFired <= 3 then
				AlreadyFired = AlreadyFired + 1
	    		local part = Instance.new("Part")
	    		part.Shape = "Ball"
	    		part.Material = "Neon"
	    		part.Size = Vector3.new(0.6, 0.6, 0.6)
	    		part.Position = waypoint.Position
	    		part.Anchored = true
	    		part.CanCollide = false
				part.Parent = game.Workspace
				Humanoid:MoveTo(waypoint.Position)
				if waypoint.Action == Enum.PathWaypointAction.Jump then
					if Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping or Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown or Humanoid:GetState() ~= Enum.HumanoidStateType.Flying or Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then 
					    Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
						print("Jump Debug")
					end
				end
			end
		end

The movement code is pretty simple, i took it from the developer hub, the current problem is the jump system, sometimes, when i’m playing with the AI, in a moment where it needs to jump, it starts to jump infinitely and goes to the sky (Literally), i’ve tried to solve the problem from checking the humanoid state, if the humanoid is not in the sky or something like that, but that didn’t help, i don’t know if this is fault of the map layout, if you can see in the code, it creates a sphere for each waypoint, well, sometimes the sphere gets created in some strange locations:
imagen
I don’t know how to solve the issue, this is my first attempt trying to make a working pet system for my own, thanks for reading.