I have a ScreenGui object that needs to be given only to administrative players. It must not be replicated to non-administrative players at all. In my game I have FilteringEnabled set to true. When FilteringEnabled is true, a Player's PlayerGui will not replicate to the server. This means that the following code in a server Script will not work because the PlayerGui is not accessible to it.
game.Players.PlayerAdded:connect(function(p)
if playerIsAdmin(player) then
--The line below does not work because PlayerGui is not accessible
-- to this script running on the server.
game.ServerStorage.AdminScreenGui:clone().Parent = player.PlayerGui
end
end
How can I replicate this ScreenGui object to administrative players only without replicating it to all players while keeping the FilteringEnabled property set to true?

7 comments
Why don't you have it replicate on PlayerAdded or CharacterAdded? You can have this in the ServerScriptService.
PlayerAdded and CharacterAdded run in server scripts. The PlayerGui is not available in server scripts. It is assumed that the above code IS running in PlayerAdded. I will edit the question to reflect that more clearly.
If it is so, then have your ScreenGui object already exist in the StarterGui, and only remove if the LocalPlayer name does not match per say you created a table.
That would mean replicating the gui to every player which is what I want to avoid. I do not want non-administrative users to ever get the ScreenGui.
Why can't you just simply set it's default visibility to false and only set to true if the player is administrator otherwise destroy it. That's all I can think of right now. It's not like they will ever see it once they join, unless you have something otherwise that detects if the player has the ScreenGui
The point is to prevent exploiters and cheaters from accessing it. It must never be replicated to the non-administrative users.
Exploiters and cheaters can't access it anyways when you use :Destroy() to remove it from the PlayerGui