Car won't restart. Have to wait 30 minutes

If it cranks but does not start, sometimes a temperature sensor is bad and the computer can’t figure out the proper amount of fuel to inject. Just a little off and the engine won’t start. After a half hour, the engine just happens to get to a good starting temperature.