Not declared in scope, I have no idea why this isn't working

Use code tags.

Can you see how this function is incorrect with where the { and }.

Please post your code in code tags.

Again there is code outside of functions.

Use code tags.