I’m trying to make a surfacegui Button that gives a player a tool that is in server storage but it is not working.
I keep getting this same error when I click the button

I’m trying to make a surfacegui Button that gives a player a tool that is in server storage but it is not working.
I keep getting this same error when I click the button

Seems like your player variable is ending up as nil. Could you show me the line of code where you define player?
There is no variable that defines the player, is that something I need?
Just realized it was part of your function.
MouseButton1Click does not pass a player parameter since it is intended to be used in client-sided code. Your code is on the server. Therefore, player is returning nil because it doesn’t exist as a parameter.
Use a click detector instead of a SurfaceGui in the workspace. You can use the .MouseClick event to detect when it has been clicked, and it also passes the player as a parameter so you can see who clicked it.
does that mean I cannot use the surfaceGui button to give the player the tool?
You can still use a surfaceGui, but it needs to be a local script instead of a server script, and you need to use the .Activated event. You can learn more about it here.