Lots of good advice here (although I wouldn’t necessarily follow the suggestion I gave earlier in the thread - it has worked, but there is also the risk of escalation.)
If it’s a pub or social club and someone is being an anus, you can ask the management to deal with them. Private events are a bit trickier, but if necessary you can stop playing and announce over the mic that you can’t be having audience members in the playing area. If this happens more than once, hopefully the audience will realise that the eejits are spoiling it for everyone else. Emphasise their safety and yours (lots of electrical equipment) rather than risk of damage to kit. Anything you can do to create a divide between band and audience will help (eg empty cases placed to prevent stage side access), but if there’s not even an actual stage then that can be difficult.