How do I add this OnClick event script to a custom button I’ve created?

How do I add this OnClick event script to a custom button I’ve created?

tech