How would I use fireallclients to make a gui appear for everyone in the server?

This is most likely a super easy question to answer, but how would I make a GUI appear for everyone on the server by having one person on the server touching a brick?

I know that I would have to use FireAllClients: but if you can go a little more definite, that would be great! :smile:

You can either;
1: Clone the GUI to everyone’s client, which doesn’t require FireAllClients
2: Fire a RemoteEvent to enable the GUI on all clients, which requires FireAllClients

First way (with cloning):
Get your ScreenGui
Use this code;

SERVER SCRIPT

local gui = -- ScreenGui here (like game.ReplicatedStorage.GUI)

for _, plr in pairs(game.Players:GetPlayers()) do
    local clonedgui = gui:Clone()
    clonedgui.Parent = plr:FindFirstChild("PlayerGui")
end

Second way (with FireAllClients):
You need to have a RemoteEvent named something.
Your GUI needs to be in StarterGui, and needs to have Enabled set to false.
Here’s the script:

SERVER SCRIPT

local event = -- RemoteEvent
event:FireAllClients(true)

CLIENT/LOCAL SCRIPT

local event = -- RemoteEvent
local PlayerGui = game.Players.LocalPlayer:FindFirstChild("PlayerGui")
local gui = PlayerGui.-- name of GUI
event.OnClientEvent:Connect(function(status)
    gui.Enabled = status
end)

Hope I helped!

1 Like