When using a Gameobject variable in a public void in C# it does not show up in button(script)

How do I fix this?

This works, so you must be missing something. Did you set up the OnClick Object reference correctly? Is the OnClick object reference linked to an existing GameObject or are you referencing the script directly? Typos or scripting errors maybe?