Answered by
5 years ago Edited 5 years ago
Assuming the part script is a ServerScript and the exit button is a LocalScript. If that is the case then this is the reason.
The first time when the GUI opens from the ServerScript, it works fine but why it won't do it a second time is because the GUI was closed from a LocalScript, and because of that the server still sees that the GUI is enabled even though it's not so it doesn't do anything.
My suggestion is to first disable the GUI and then enable it:
1 | script.Parent.Touched:connect( function (hit) |
2 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
3 | game.Players:GetPlayerFromCharacter(hit.Parent:FindFirstChild( "Humanoid" ).Parent).PlayerGui.shop.Enabled = false |
4 | game.Players:GetPlayerFromCharacter(hit.Parent:FindFirstChild( "Humanoid" ).Parent).PlayerGui.shop.Enabled = true |