Function a nil value?

I’m extremely new to lua and I’ve been going to the wiki, I came across a couple of gamemode guides so I’m currently experimenting with them, learning about the global functions and some sexy derma but sadly I’ve run into a problem I’ve looked at the code over and over again and I just can’t work out what the problem is - I’m going to guess I’m doing something stupid or something that I’ve not found and that is why I’m getting the problem.

Anyway,

That is the error message I’m getting also why is it trying to call a global, now for the code.

Any solutions also any tips I should know as I’m just starting out in lua and they would be really useful.

Regards,
Pridit

EDIT: Fuck I think I had to end the if statement and the function, fuck yeah it was that sorry for wasting your time guys.

You forgot to end the StaffCheck function.