In a previous study (Phys. Rev. B 96 (2017) 144501), a strong variation in the superconducting transition temperature T
c of YB6 differing by a factor of two has been explained by a change in the density of yttrium and boron vacancies tuning the electron-phonon interaction. Here, by using an array of miniature Hall probes, we address the penetration of the magnetic field, pinning, and critical current density on a series of YB6 single crystals with T
c variation between 4.25 and 7.35 K. The analysis of the superconducting and normal-state specific heat characteristics allowed us to determine T
c and the stoichiometry of our samples. We observed almost no pinning in the most stoichiometric YB6 crystal with the lowest T
c. Upon increasing the number of vacancies weak pinning appears, and the critical current density is enhanced following the increased transition temperature in a linear variation. We argue that such an increase is, within weak collective pinning theory, consistent with the increasing number of vacancies that serve as pinning centers.