I am having trouble making a GUI pop up when the player is touching a part, but then the GUI disappears when the player is not touching the part.
The part that I want the player to touch and activate the GUI is called 'Part'. The GUI is called 'GUI'.
The tree goes like this, Workspace > Part > Script > GUI
This is the code I have so far:
script.Parent.Touched:connect(function(char)
local player = game.Players:GetPlayerFromCharacter(char)
if player and not player.PlayerGui.GUI then
script.GUI:clone().Parent = player.PlayerGui
end
end)
script.Parent.TouchEnded:connect(function(char)
local player = game.Players:GetPlayerFromCharacter(char)
if player and player.PlayerGui.GUI then
player.PlayerGui.GUI:Destroy()
end
end)
When I test, the GUI just doesn't come up on screen when I touch the part.
How do I fix this??

6 comments
It works great! How do I accept your answer?
You should see it at the bottom of my answer. You can also give an upvote by pressing the arrow that is pointing up like " ^ "
There's no up arrow :(
Do you see the "Accept Answer" button below this comments section?
No it just says 'report'
Well, that is weird.