1 | part = game.Workspace.partname |
4 | part.Touched:connect( function (hit) |
5 | player = game.Players:GetPlayerFromCharacter(hit.Parent) |
6 | if not player.PlayerGui.guinamehere then |
7 | gui:Clone().Parent = player.PlayerGui |
This piece of code should work.
Change the variable part to the parts location that you want to activate the touched function.
Change the variable gui to the gui's location
Change guinamehere to the name of the GUI
If you'd like the part to remove the gui if its already open we can do this by adding something simple:
01 | part = game.Workspace.partname |
04 | part.Touched:connect( function (hit) |
05 | player = game.Players:GetPlayerFromCharacter(hit.Parent) |
06 | if not player.PlayerGui.guinamehere then |
07 | gui:Clone().Parent = player.PlayerGui |
08 | elseif player.PlayerGui.guinamehere then |
09 | player.PlayerGui.guinamehere:Destroy() |
If this doesn't work please let me know any error(s) outputted and I'll help you fix it.