✓ Accepted answer
You don't have a debounce in your client code.
You should add a debounce, into your client code; the debounce is to limit how often the function connected to the click event can be executed.
local ShowGui = game.ReplicatedStorage.Menu
local debounce = false;
script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = true;
ShowGui:FireServer()
wait(0.2);
debounce = false;
end
end)
Without the debounce, there is no telling how many times your script will end up firing to the server to create a new GUI.
To add, if the UI you are dealing with is only to remain over the client, then it is not necessary to execute cloning and such over the server. In FE local scripts can manage things such as UI (i.e. GUI, and sound), the client character's animation, and the client character's movement.
You should also be sending distinct information to the server from your ShowGui remote event if it is true that you are firing it for more than one purpose.
A remote event does not only fire the local player over to the server, it also fires some optional input specified by you.
Server:
local ShowGui = game:GetService("ReplicatedStorage").Menu
ShowGui.OnServerEvent:Connect(function(player, my_input)
if my_input == "input" then
game.ServerStorage.GUI.TheMenu:Clone().Parent = player:WaitForChild("PlayerGui")
end
end)
Client:
local ShowGui = game.ReplicatedStorage.Menu
local debounce = false;
script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = true;
ShowGui:FireServer("input")
wait(0.2);
debounce = false;
end
end)
Of course you can always change what input you are sending to the server and such.
4 comments
Why did you hook up a server script to do it? It's just to open a gui on someones UI.
you don't need remote events for this since it only changes what one player sees
Originally I had it like
a four line mousebutton1click where it just cloned it from the serverstorage but that didnt work with FE