script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Frame = false end)
You're going to want to use Locals. Is the script inside of the button? Put the script into the ScreenGUI, define the button and frame and ensure that it is localized correctly.
local button = script.Parent.TextButton local frame = script.Parent.Frame function Click() frame:Destroy() end button.MouseButton1Click:Connect(Click)