Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Replicate ScreenGui to certain players only when FilteringEnabled is true?

Asked by
AxeOfMen 434 Moderation Voter
10 years ago

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?

0
Why don't you have it replicate on PlayerAdded or CharacterAdded? You can have this in the ServerScriptService. Dummiez 360 — 10y
0
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. AxeOfMen 434 — 10y
0
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. Dummiez 360 — 10y
0
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. AxeOfMen 434 — 10y
View all comments (3 more)
0
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 Dummiez 360 — 10y
0
The point is to prevent exploiters and cheaters from accessing it. It must never be replicated to the non-administrative users. AxeOfMen 434 — 10y
0
Exploiters and cheaters can't access it anyways when you use :Destroy() to remove it from the PlayerGui Dummiez 360 — 10y

Answer this question