Hello, I am using a gui, and I want it to effect all players, the problem is that I only know how to use local scripts with guis, and if I copy and paste the code into a normal script it doesn't work. What should I do? Thank you.
How do I make A GUI effect more than the local player?
1 answer
You need to use a RemoteEvent to fire a local event to the server. Insert this is the event of the LocalScript (What makes the Gui visible.)
local event = Instance.new("RemoteEvent", game.ReplicatedStorage)
event.Name = "GuiEvent"
--Put this in your function.
event:FireAllClients()
That's not all. We need to connect the event to the server.
Put this in a Script in ServerScriptService.
local gui = "GUI" --Make this the name of your Gui.
local event
local replicatedStorage = game:GetService
local waitEvent = replicatedStorage:WaitForChild("GuiEvent")
local players = game.Players:GetPlayers()
if waitEvent then
event = waitEvent
end
event.OnClientEvent:Connect(function()
for _,player in pairs (players) do
local playerGui = player:WaitForChild("PlayerGui")
playerGui[gui].Visible = true --Do whatever you want to do to the Gui.
end)
Hope this helps!
Don't forget to accept this answer if it worked!
No, seriously though. I spent a long time writing this.
5 comments
This didn't work, this won't just effect the gui, right? well if it does then this is unfortunately not the right answer. I tried the script and it doesn't work :( I am probably doing something wrong though so I will try fixing it tomorrow.
Did you put event:FireAllClients() in a function?
Did you change "GUI" into the name of your GUI?
It says FireAllClients can only be called from the server in the output
Hmm, try :FireServer()
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Sir, this is not constructive.