I am currently making a system whereby everyone needs to be equipped with a GUI at the same time when I press the button, but I do not know how. Currently when I click the button, it only gives the player who clicked it a gui.
How do I make it so that when I click a button, everyone in the server will receive the GUI?
I have researched and seen people using FE things like fireserver, but I do not know how to execute it.
When 1 player clicks a button, fire a remote event and then on the server you can clone as many guis as needed and parent them to each player’s playergui.
I should suggest you do everything server-sided
For example, whenever someone pressed, you loop through all players and get they gui and change it
For example:
button.Activated:Connect(function()
for i, v in pairs(game.Players:GetPlayers()) do
local playerGui = v:WaitForChild("PlayerGui")
playerGui.YourGui.YourText.Text = "Your thing."
end
end)
You can make some variables to check if it is open or not.
Remote event work, but since creating a remote would give you risks of exploiter, if you don’t have a good anti-exploit system, so why creating a remote event when you can do it all on the server-side
If you fire a remote event when they click the button then it should work. I did this with a Game Teleport button once. If this isn’t solved then I’ll give you the modified model.
But for me, I would always rather choosing secure/clean script instead of making it simplier and when it get popular or go viral, stuffs go wrong and you have to rewrite some of them
It’s really bad practice to adjust client UI from the server. In this scenario, if a client has a slow internet connection or is having a hard time loading in, the script could delay for a long time, causing players to see the graphic much later than other players. Many players might not see the graphic at all if even one of the following things happens:
A player disconnects while the loop is executing, which is very possible due to the yielding
An exploiter deletes a UI element necessary for this to work, throwing an error
Any one of the many objects hasn’t spawned in yet
The server can’t expect anything about the client to be guaranteed, thus changing UI from the server will always have the potential for errors no matter how well you code it. Calling FireAllClients on a RemoteEvent and managing the UI visibility on the client is always the safer, more reliable route to go. It also makes the UI more snappy since you’re not dependent on the connection of other players.
There are other issues as well. Just earlier today I explained an issue where the client wouldn’t replicate to the server, thus preventing certain changes from replicating properly: Clicked working only once? - #2 by ChipioIndustries
It’s always worth the extra work up front to reduce the crazy amounts of headache and jankiness that will inevitably come later. Even if you can patch it up to the point where it doesn’t happen much, if you ever expect your game to become popular, you’ll be dealing with hundreds and hundreds of error reports at scale. Never handle UI from the server.
The way you did it should work, and it isn’t right to use a remote event for functions like these, remote function would be more antiquate since it’s able to send and return data throughout it’s usage and is overall a better function to be used when being regarded with client sided actions.