How do you make a GUI stop appearing?

I just fixed a script for you above. Make sure to copy it and try again. I recommend to open a output window inside of a studio since you made mistakes inside of a script and I am sure that output should warn you about it.

Thanks! One more thing, how do I make it wait 5 seconds before it gives the ticket. I know I have to use β€œwait” but where do I put it.

Just add a wait at this part of the script:

if not alreadyHasTicket then
   wait(5)
   ticket:Clone().Parent = Player.Backpack
end

Make sure to mark a solution since there might be people with same problem in future and this article might help them out as well, thanks.