This little piece is sticking out. This is my first bike and I was wondering if it’s a problem or I should try and attach it to the bar or if it’s okay to be like that?? Help I’m new to the bike world.
Your picture isn't exactly clear but it looks like the cable with crimped ferrule from the front derailleur.
If it is hitting your crank arm as you pedal, the cable is too long and needs to be cut shorter with a new ferrule crimped to the end. Any bike shop should be able to do that procedure for little or no money.
Just do not try to cut it shorter with wire cutters; shifting/brake cables are very tightly stranded and need a very sharp, bypass-style, cutter to make a clean cut. The crimped ferrule is paramount to prevent fraying at the cable end.