Hi, i have a script that opens a gui after clicking a button (clickdetector btw) and on the gui theres a close button. However, after i closed the gui using the close button i can’t open back when clicking the clickdetector button. Why is this happening?
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player.PlayerGui.SyufGUI.SyufFrame.Visible == true then
player.PlayerGui.SyufGUI.SyufFrame.Visible = false
end
end)
You should reference the click detector from the same local script that makes the gui close. Everything in the same localscript. Like this:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.PlayerGui.SyufGUI.SyufFrame.Visible = false
end)
workspace.Part.ClickDetector.MouseClick:Connect(function() --Change the path of the click detector to your path.
player.PlayerGui.SyufGUI.SyufFrame.Visible = false
end)
The problem you had is that you were making the gui visible first on the server, which makes it replicate to the client, but then you were closing it in the client, which does not replicate to the server, so the gui was never closed in the server, and when you tried to open it for the second time it didn’t because it was already opened. Sorry if the explanation is a bit confusing.