Is there a way to access all players PlayerGui (Filtering Enabled)
You can, but the downside is that the server can't mess with the client's stuff (Ex, ScreenGui, LocalScript, etc). You can, however, use remotes to counter that, by having the remote communicate with the server. (The link can be found here)
The most simple method to add any sort of content to a player, which I don't understand the need to not use the StarterGui or StarterPack services for this, is to loop through the Players service (via a for loop, and the GetPlayers function; I recommend against using GetChildren
when it comes to looping through the Players service: What if there was an object that wasn't a player in it, and you tried to get the player's character?)
local CurrentPlayers = game:GetService('Players'):GetPlayers() -- Call for the service, then retrieve a table for the players in the game for i, v in next, CurrentPlayers do -- Loop through the table if v:FindFirstChild('PlayerGui') then -- Check if PlayerGui is there local Content = ... -- wuteva -- Other code necessary Content.Parent = v.PlayerGui -- Put the stuff into the player's PlayerGui end end
To note when I mentioned about having to use remotes: When you have FE (Filtering Enabled) activated, a server script can NOT mess with anything on the client's side, even if it made the stuff itself (The server script). (An example would be to go to/create a new place, make sure it was FE enabled, add Kohl's admin, say ":commands", then try scrolling: It wont work.) To do this, you'd have to use remotes for it. (Click here to go to the wiki page)
Junk mentioned, but didn't really talk about
Remotes - A way to have scripts communication with one another. (Like server-to-client, and vise-versa)
For Loops, but because there's two different, I'm going to list the two:
2a. Generic For - To put simply, it iterates through a table; However, to be wary, it doesn't go within a specific order. (Not sure what example to give)
2b. For Loop
- Iterates/loops a number of times. (For example, for iteration = 1, 10 do
would loop 10 times, then stop)
GetPlayers - In a nutshell: Creates a table, then puts the players in that said table. :P (Can only be used with the Players
service)
Filtering Enabled/Experimental Mode - Where only things done by the client also replicates to the client, but a server can do more stuff, but can't mess with the client, unless done through a remote. (Remotes still have weaknesses if you're not careful)
FindFirstChild - Iterates through an object's assets, via obj:FindFirstChild('Object')
, and the first object that it found will be returned, otherwise it'll return nil
. However, there's a second, optional argument to the function, which will also search through descendants. obj:FindFirstChild('Obj', true)
If you don't give it the second argument, by default it'll be set to false.
I hope this helped. c;
You can. You just need to get the players using GetChildren
.
for i,p in pairs(game.Players:GetChildren()) do --for every player local playerGui = p.PlayerGui --get their playergui and index it into a variable local newGui = Instance.new("ScreenGui",playerGui) --inserting a new gui into each players gui end
Please accept my answer if this helped!
This should work
local Players = game:GetService("Players"):GetChildren() for _, v in pairs(Players) do if v:FindFirstChild("PlayerGui") then local Gui if Gui then local AllThePlayersGui = v.PlayerGui:WaitForChild(Gui) print(Gui.Name) else print("Gui Could not be found") end end end
change the variable called Gui to your gui and add the code in the area where it says "if Gui then"