Pull the slider completely off the zip then have a good look at it to see if it needs replacing. If the space between the bottom and top of the slider is uneven then it will stop the slider from engaging with the teeth which will make them come apart. (If the slider looks fine then you will be able to fix it by putting it straight back onto the zip).
The size of the slider should be embossed on the back of it. If it isn’t, measure across the teeth from side-to-side in millimetres. For example, if the teeth measure 5mm wide then you will need a size 5 slider. Sliders can be bought online or in haberdashery shops.