You give us very little info to help you out, but I’m guessing you either have a fuel or spark problem. Simple test to determine which. Next time it happens spray some carb cleaner directly into the carb with the air filter removed. If it starts but immediately dies, I would say you have a fuel delivery problem. Open the fuel cap and let sit for about a minute, then retest with carb cleaner and see if it stays running this time. If it stays running, I would be replacing the fuel cap, as the vent is plugged and a vacuum is being created in the tank, not allowing fuel to flow from tank to carb. If the unit will not start with carb cleaner it is time to check for spark. Remove a spark plug, reinsert it into the boot and have a helper hold it against the engine while you try to start the unit. They will be looking for a spark at the plug. If NO spark your coil has either a hot short or hot open. In either case you will be replacing the coil. When you report back your findings, please include your engine brand and all model, type, code, spec and serial numbers. With out them we are only guessing what you are looking at and it makes it harder to help you.