How should I go about opening a GUI with a server part?

I have a boat in the workspace that contains a ClickDetector, once the boat is clicked a travel UI will show up for the player. When doing this should I just put the UI opening code in the ClickDetector script or use a Remote Event to open the UI for that player?

Example:

script.Parent.ClickDetector.MouseClick:Connect(function()
    -- Open the UI
end)

-- OR

script.Parent.ClickDetector.MouseClick:Connect(function()
    game.ReplicatedStorage.RemoteEvent:FireClient(Player) -- Open the UI this way
end)

I know this code doesn’t represent how actual code looks or proper directories, it is just written for the purpose of delivering my point.

While you could just open the GUI on the server side, I’ve found that firing an event to manage client sided GUIs is better in the long run. They can sometimes clash, and mess things up, as the playergui will always remain client sided, and if you ever make a change to a player gui, the server does not see those changes, and will completely ignore that they ever happened.

I was once tweening guis, and thought I could get by with having the server tween them, but I also had some local scripts that also tween the gui. Let’s just say that it broke very quickly as the server didn’t recognize any tween that I had made with local scripts.

1 Like

Honestly, it doesn’t matter. You can do either. You can clone the GUI to the PlayerGui through a ClickDetector without actually having to fire any remote events.

local function click(player)
    local gui = game.ServerStorage.ScreenGui -- obviously change this to where your GUI is.
    gui:Clone().Parent = player.PlayerGui

script.Parent.ClickDetector.MouseClick:Connect(click)

Alternatively, you could also fire a RemoteEvent. Either is going to work. Firing RemoteEvents to the client may be more reliable though. You should experiment with both and see which works better for you.

1 Like

Its useless, use just localscript inside ClickDetector, it would run command on client.

1 Like

I’ll just go with Firing the Client seeing as it is the most reliable way I have noticed in the past, I’ve just seen many people do either so I wanted to hear the feedback on which was most reliable. Thanks!

I’ve also heard that ClickDetectors aren’t super reliable and I should use a LocalScript to see what the player clicks on using the mouse’s hit propety and then fire the client using a remote event. Would that be a good use to or will the ClickDetector work just fine?

just place click detector on right place. Make HitBox of it.


green part its clickdetector

I don’t mean unreliable via sometimes it won’t detect a click, I meant it’s unreliable because of it’s conflicts with FilteringEnabled as I’ve been told in the past.

Well, its depends on your opinion.

1 Like

I think a ClickDetector will be fine for Client Events, just not reliable for Server Events, so I’ll stick with the ClickDetector.