do i really not let people love me?

my boyfriend recently broke up with me. he said he felt like i kept a barrier around myself and didn’t let him love me. my dad left with i was a kid and then my mom got remarried. then 4 years later my stepdad left. he thinks that i am scared he’s going to hurt me so i just don’t let myself love him. and i keep him at a distance. i don’t know if it’s true but if it is i just ruined a really nice relationship and i don’t know how to be better in the future.