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.
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.
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?