I want to make a Screen GUI visible in a server script that goes to all players. I am fairly new to scripting and I have no idea how to do this. If anyone can help, please reply to this topic.
You cannot do this with a server script. But you can do it with remote events. Learn more here.
im pretty sure that if you make a event and make all player’s gui visible will do the job
So do I have to like make a localscript under the screen gui that makes a server event that then fires all clients?
If you want to give a UI that is in the script (you can modify this) to every single player, you can do this in a server script:
local ScreenUi = script.ScreenGui -- Your UI
local Players = game:GetService("Players")
function GiveUiToAllPlayers() -- The function that will give the UI to everyone
for _, Player in pairs(Players:GetPlayers()) do
local CloneUi = ScreenUi:Clone()
CloneUi.Parent = Player.PlayerGui
end
end
GiveUiToAllPlayers() -- This gives the UI to everyone
-- You can also create a RemoteEvent and trigger the function with it
You make a server script that fires to all the clients through the remote event. Then you make a local script that can retrieve the fired event.
that is not very good tbh i suggest you just make it visible instead of clone one
(clone works too tho just my opinon)
I just want a screen gui that can go invisible and visible.
Yeah sure but this is the best way (I don’t know any other) if you want to make it as secure as possible (talking about exploiters).
yeah his script is like cloning the gui then give it to all players
server stress will cause bad gameplay ;-;
just my experience
Then you can do what @foxnoobkite said, just make a RemoteEvent in ReplicatedStorage and then fire it on server, also make a localscript (probably in the ui) on the client and listen to the RemoteEvent when it fires and make it visible/invisible.
Use a remote event and do something like this:
Local script:
local RE = game.ReplicatedStorage:WaitForChild("RemoveEvent")
script.Parent.MouseButton1Click:Connect(function() -- change this event to whichever way you want to activate the script
RE:FireServer()
end)
Server Script:
local RE = game.ReplicatedStorage:WaitForChild("RemoveEvent")
local function open()
game.StarterGui.ScreenGui.Enabled = true
end
RE.OnServerEvent:Connect(open)
This would only show the UI in StarterGui aka it won’t update to all players, only new players would get the visible UI. Just use for loop to enable it for all players.
Ima try to test it out, hopefully, it works!
tbh depends on what you want the gui to pop up for…
Should I make it clone every time and give it to every player? Or should I just make it visible and invisible over and over again?
Well if you clone it every time then I think the solution I posted before is also good, except it doesn’t listen to any events. I think the best solution is the one @foxnoobkite suggested.
Why is everyone posting that? Is something wrong with my question?
nope i just made a mistake and deleted my answer