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

Displaying GUI for each player via RemoteEvent/RemoteFuntion?

Asked by 6 years ago

I have some conditions in the local script. After it is completed, all players need to show gui (clone it from-somewhere). how can I do it? Should I use remotefunction / event?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

The easiest way to do this is to already have the gui in each player's PlayerGui, and take advantage of FireAllClients.

FireAllClients is the same as using FireClient, except it fires all of them. Use this on a RemoteEvent in ReplicatedStorage from the server, and have a LocalScript on the client that recieves it using OnClientEvent.

Server:

--Game script?
local re = game.ReplicatedStorage.GuiStuff; --This is your RemoteEvent

while wait(60) do
    --codecodecodecode
    re:FireAllClients(true); --Send a bool argument for visibility
end

Client:

local re = game.ReplicatedStorage.GuiStuff --This is your RemoteEvent
local ui = script.Parent; --This is the gui

re.OnClientEvent:Connect(function(on) --'on' parameter for bool argument
    ui.Visible = on;
end)
Ad

Answer this question