Gui not opening again

I am making a Shop where if you click the NPC, it opens the shop GUI and closes the Close button. So far it works but if I close the shop and try to open it again it won’t open. Here is the script inside the click detector which is inside the NPC:

script.Parent.MouseClick:Connect(function(player)

player:WaitForChild("PlayerGui").ToolShop.Frame.Visible = true

end)

But here is the script inside the close button:

script.Parent.MouseButton1Down:Connect(function(player)
	game.Players.LocalPlayer.PlayerGui.ToolShop.Frame.Visible = false
end)   

What is wrong?

In the first script is the script parent a ClickDetector?

yes It is. Its inside the click detector which is inside the npc

Try using a ServerScript to close the gui or use a RemoteEvent and Fire the client to Open and Close

Is there any error messages? Maybe it can help us.

Try this for the click detector waitforchild might be the problem

script.Parent.MouseClick:Connect(function(player)

player.PlayerGui.ToolShop.Frame.Visible = true

end)