Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make A GUI effect more than the local player?

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.

1 comment

1

Sir, this is not constructive.

1 answer

✓ Accepted 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

0

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.

0

Did you put event:FireAllClients() in a function?

0

Did you change "GUI" into the name of your GUI?

0

It says FireAllClients can only be called from the server in the output

0

Hmm, try :FireServer()

This discussion is preserved as it was. New answers, comments, and votes are closed.