transistor and resistor

why when i use a transistor at the base i have to connect a resistor? if I don't connect it, why doesn't the circuit work? thanks

Because, a transistor is a current controlled amplifier, not a voltage controlled amplifier.

Your post begs the question:
"why are you using a transistor when you know nothing about them ?"
It's not an appliance you just plug in.
Research devices before using them. That's just
common sense. Would you try to to fly an airplane
if you weren't a pilot ?
Statistics show that a very high percentage of gun
accidents are caused by the users simply not knowing basic gun safety such as yelling "Halt !
Identify yourself !". Instead they see a figure in their house in the shadows at 1:00 in the morning
and open fire without saying a word only to discover to their hortor tgat it is their teenage son
sneaking back in the house after meeting friends
or a girlfriend. In the age of Google, it is amazing
and shocking how few people take advantage of this incredible source of unlimited information.
A google search for "transistor" would yield many millions of hits in seconds, yet you spend more than that to ask a silly question.