Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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
Sir, this is not constructive. alexfinger21 341 — 4y

Closed as Not Constructive by alexfinger21, moo1210, zblox164, youtubemasterWOW, and Fifkee

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago
Edited 4 years ago

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.

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. Mrawzomeperson -3 — 4y
0
Did you put event:FireAllClients() in a function? DesertusX 435 — 4y
0
Did you change "GUI" into the name of your GUI? DesertusX 435 — 4y
0
It says FireAllClients can only be called from the server in the output Mrawzomeperson -3 — 4y
0
Hmm, try :FireServer() DesertusX 435 — 4y
Ad