Oven won't light

The oven gas comes on and clicks around 5 times but won’t ignite. Sometimes it works, the broiler works sometimes as well. Based on what I’ve read I figure I need to replace the igniter, is that the case if it lights sometimes.