Hey Janshi
Your problem sounds like an issue with your wifi-network. I hope you find a solution for it.
Concerning your script: I think you'd be better off creating a new custom workflow for it, since it does something completely different to the toggle-wifi script.