How CAN I solve this problem?

This should be done the RemoteEvent way. Since if someone else clicks the ClickDetector it will still fire the MouseClick event on all the other Clients. Which causes unnecesary Network Traffic.

So you would have a Remote Event in ReplicatedStorage and then the Server Script would Fire the Event to the Player who clicked it using RemoteEvent:FireClient(player). Then on the LocalScript u would open the Gui.

So I only write RemoteEvent:FireClient(player) on the server script and on the local script (CLOSE BUTTON LOCAL SCRIPT) and on the part scrtipt I will also have to write some line right? Which lines?

NOTE: Before trying the method 2, try method 1 first.

Method 1:
Try doing it all in one single Local Script.

Try something like this:

Frame = (Frame location here)
clickDetector = (Click detector location here)

function onMouseClick()
	Frame.Visible = true -- Or false
end

clickDetector.MouseClick:connect(onMouseClick)

I think the problem might be with using “MouseClickButton1Click” instead of “MouseClick”. From what I remember, “MouseClickButton1Click” is only for buttons, not click detectors. Read more about it in the link directly below this.

Good guide if you wanna check it out: https://developer.roblox.com/en-us/api-reference/class/ClickDetector

Method 2:
You could try this:

Have 1 Localscript that says this:

clickDetector.MouseClick:Connect(function()
RemoteEvent:FireServer()
end)

Then have one server script in ServerScriptService that says something like:

RemoteEvent.OnServerEvent:Connect(function(player)
RemoteEvent:FireClient(player)
end)

And then in the same localscript from earlier, put:

RemoteEvent.OnClientEvent:Connect(function()
Frame.Visible = true
end)

Basically what this is doing is,

  1. When someone clicks the button, the LocalScript fires the RemoteEvent to the Server
  2. The ServerScript receives the “FireServer” and fires the RemoteEvent back to the client
  3. The LocalScript receives the “FireClient” and does whatever you want it to

There’s probably better ways of doing this, but this a starting idea at least, that worked for me. And here’s something to look at: https://developer.roblox.com/en-us/api-reference/function/RemoteEvent/FireClient

P.S. In the first section of code I sent you, I’m not sure exactly how to make it fire to that specific player. I just put a “player” parameter in the function and the FireClient. You might have to change that.

I would just handle everything on the client or local script for the clickdetector and the GUI stuff. It’s more simple anyway

If you wanted you could handle the mouseclick on the server and fire a remote event to the client where it open a GUI. I would do it through starter GUI and not PlayetGUI. That’s just my preference.

heres my solution when you click the part its not work bc i already try this but one simple solution on it here the script

local part = workspace.Part
local CD = part.ClickDetector

local Frame = script.Parent – the local script is parent by the frame you dont need to put the normal script just you need is the local script on the frame

CD.MouseClick:Connect(function()
Frame.Visible = true
end)

and the button of the GUI is here

Frame.Button.MouseButton1Down:Connect(function()
frame.Visible = false
end)

hope it help you

Try doing it without the “WaitForChild(“PlayerGui”), instead just do player.PlayerGui.

Also, make sure that “player” is correct, and that it’s not “Player” with capitalization.