This is giving a player with a tool so this will need to be a local script because I think your giving a tool to a player and not to every player right???
Its a little hard to explain, but to put it shortly, it has to be done in this server script. cant be a local script as that would be outside the main handler. It is possible to-do within a server script, im just struggling to get it to work
It’s 2 am right now so sorry if I get this wrong or it’s not the best explanation, but (assuming that it’s a SurfaceGui), you can’t get the player from a SurfaceGui. Since it’s a server script you’d need to make it a local script and use a remote event to give the tool from the server.
Though i was doing it at like 4am so I just gave up in the end and had it print a physical ticket which can be taken with a proximity prompt, which is some ways is better than it just magically appearing in your inventory.