Because you a few always opening it, your scritp should look lite:
local prompt = path
local button = path
local LocalPlayer = game: GetService(“Players”).LocalPlayer
local open = false
prompt.MouseClick:Connect(function(Player)
if open == false then
Player.PlayerGui.Blogs.one.Enabled = true
open = true
end)
end)
button.MouseButton1Click:Connect(function()
if open == true then
localplayer.PlayerGui.Blogs.one.Enabled = false
end)
This is obviously a server script. When the server enables the UI, you see it because it’s replicated (Server → Client), but when you disable the UI via a LocalScript, it doesn’t replicate and the server still thinks the UI is opened (Client → Server X).
Use RemoteEvents.
Also, you need to decide whether you want to go client-sided or server-sided. You can’t just go both sided together. Now without the use of RemoteEvents, I have three-different methods.
1st Method
local prompt = script.Parent
prompt.MouseClick:Connect(function(Player)
Player.PlayerGui.Blogs.one.Enabled = true
local button = player.PlayerGui.ScreenGui.Whateverbutton
button.MouseButton1Down:Connect(function()
Player.PlayerGui.Blogs.one.Enabled = false
end)
end)
2nd Method
local prompt = script.Parent
local plr
prompt.MouseClick:Connect(function(Player)
Player.PlayerGui.Blogs.one.Enabled = true
plr = Player
end)
local button = plr.PlayerGui.ScreenGui.Whateverbutton
button.MouseButton1Down:Connect(function()
Plr.PlayerGui.Blogs.one.Enabled = false
end)
You don’t really need to have this on the server, as everyone has already said, its just GUI. I’d understand if it was something more important but
ping will be a factor for GUI events since its now run on the server
far more confusing and requires more locals and paths
is generally slower and less efficient
i’d just do this all locally instead, its far better and more efficient.