Help with sidescroller

would someone be able to make a tutorial or explain how to spawn enemies like in the game dad & me

i have everything lined up already for the game im making but i just need to set it up so that once my char reaches a certain x distance the enemies will spawn and he wont be able to leave until they are defeated.