Upvote:13
The question has basically already been answered in the comments, but here we go, also with a few possibilities to solve the problem.
If you are correct with your statement in the question, that you are not allowed to enter Croatia, you will only have a single-entry Schengen visa. In this case, you will neither be allowed to take the bus from Venice to Zagreb, nor would you be allowed to take the bus from Zagreb to Budapest if you still somehow managed to reach Zagreb. To travel from Zagreb to Budapest, you would reenter the Schengen area and since your single-entry visa has already been 'used up', you would not be let in a second time.
If you still want to travel with FlixBus, you have at least two other options:
There are direct buses from Venice to Budapest. As far as I can find out, all of them go via Ljubljana and Maribor, so you will stay within the Schengen area for the entire trip and be safe. I might have overseen some exception here, so please verify with FlixBus that you are good if you decide to book one of these.
There are also connections with a transfer in Vienna. These are definitely staying within the Schengen area for the entire trip, so these are 'safe'.
I can't find any prices online, but there is at least one daily and reasonable train connection from Venice (departing 09:55) to Budapest (20:19) with a transfer in Vienna. Also this connection will stay within the Schengen area.
If you actually have a multi-entry Schengen visa, and as Torsten S already pointed out enough entries left to use, you are actually allowed to enter Croatia with your current Schengen visa and the trip you have booked is not a problem at all.