Barcelona is a wonderful city with a lot of attractions but also a lot of pickpocket thieves. Please, never leave your belongings unattended, especially in the city center, and only carry the absolutely necessary with you. A key recommendation is that you leave your passport and at least one credit card or some cash in the hotel to ensure that you can travel home without having to pass by the consulate of your country (https://www.introducingbarcelona.com/consulates).
A good list of safety recommendations can be found here: https://onefamhostels.com/16-essential-tips-how-to-safeguard-your-safety-barcelona/