I wanted to make a screen gui that pops-up when player touchs a part and closes after the player stops touching the part and i want it to be clickable but i could only do this
script.Parent.Touched:connect(function(hit)
humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.ScreenGui.TextButton.Visible = true
wait()
end
end)

4 comments
You need to add Textbutton.Visible = false, but I think you have that covered. Did you even call the function anyways?
does this work already ? plus you might wanna add a debounce
I don't suggest you to use the Touched event, instead check for the distance of the player from the part, so that you can easily tell whenever the player steps in / out.
You've done it right, but you gotta do player.PlayerGui.ScreenGui.Enabled = true instead for player.PlayerGui.ScreenGui.TextButton.Visible = true at line 5!