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?
✓ ANSWER ACCEPTED
Displaying GUI for each player via RemoteEvent/RemoteFuntion?
1 answer
✓ Accepted answer
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
