Hello there!
I’m trying to make a screen gui that appears for all players after a certain thing happens in a normal script. I have made it work and appear when a player resets, but I need it to work right as it’s called. How would I do this? The Gui is an image label and text label in a frame in a screengui in starter Gui.
4 Likes
From the Server you can fire a remote event to all the Client.
Like RemoteEvent:FireAllClients()
then in a local script Receive it , RemoteEvent.OnClientEvent:Connect(function()
and change the GUI visibility.
1 Like
I’m not too good with remote events, yet. Is there any other way I could do it via script?
1 Like
Well you can Loop through all the Players and get their PlayerGui and Change the Visibility , but I won’t suggest that.
Remote events are really easy and you should definitely get used to using them,
The FireAllClients() is basically sending a call to all clients
The OnClientEvent is waiting to get the call on each client, once it does, it runs a function
Add a RemoteEvent in ReplicatedStorage, I’ll just call it ‘RemoteEvent’
-- Inside a script (perhaps in ServerScriptService):
local replicatedStorage = game:GetService("ReplicatedStorage")
local removeEvent = replicatedStorage:WaitForChild("RemoteEvent")
remoteEvent:FireAllClients() -- this will be placed after a certain thing happens
-- Inside the LocalScript
local replicatedStorage = game:GetService("ReplicatedStorage")
local removeEvent = replicatedStorage:WaitForChild("RemoteEvent")
remoteEvent.OnClientEvent:Connect(function()
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
-- You can either enable the GUI (when disabled beforehand)
-- or just make the frame(s) inside of it visible
player.PlayerGui.GuiName.Enabled = true
-- Or
player.PlayerGui.GuiName.Frame.Visible = true
end)
4 Likes