Making a gui that only certain Players can see

So how do I make a Gui Only certain players can see for like moderators in game.

local moderators = {“Frepzter”,“FrepzterRB”}

—show gui

Please help me i already tried it but its not working

local BronzeTiers = {“Frepzter”,“FrepzterRB”}

while true do
for i,verify in pairs(BronzeTiers) do
if verify == script.Parent.Parent.Parent.Name then
warn(verify…" is a moderator")
script.Parent.Enabled = true
warn(verify…" is not a moderator")
script.Parent.Enabled = false

What’s not working? You need to be more specific

You can use table.find(moderators, Name) to see is the player in the table.

The error is that the gui, It doesn’t show the gui

You only set it to Enabled. Try

script.Parent.Visible = true

ScreenGui only has an Enabled property

I thought there would of been a frame…

What you should do is check this on the server and then parent the ScreenGui class to the player’s PlayerGui.


local ModeratorIds = {1, 2, 3, 4}
    if table.find(ModeratorIds, Player.UserId) then
        gui_path.gui:Clone().Parent = Player:WaitForChild("PlayerGui")

@Wxeeknd works brilliantly however it doesnt reappear when player respawned i tried making a characterAdded Event but still wont work

local ModeratorIds = {288094249}
local plrService = game:GetService(“Players”)
if table.find(ModeratorIds, Player.UserId) then
game.ServerStorage.BronzeMod:Clone().Parent = Player:WaitForChild(“PlayerGui”)

works brilliantly however it doesnt reappear when player respawned

You can untick ‘Reset on Spawn’ in the properties of the Gui if you don’t want it to reset

1 Like

Thanks idk why i forgot that that existed (nvm still doesnt work the gui gets deleted somehow)

Don’t forget to mark a solution to close the issue.

It doesn’t work still it gets deleted idk why it gets deleted

well you could do if table.Find(admins,userid)
then do local yes = GUI:Clone()
yes.Parent = p.PlayerGui

Setting “Reset on spawn” to false should do the trick, unless there is some other script interfering.

An alternative is to move the GUI to ReplicatedStorage then make a script in ServerScriptService that goes along the lines of

local gui = game.ReplicatedStorage[""] --fill in quotation marks with name of gui | this defines the pathway

local moderators = {"Frepzter", "FrepzterRB"}

game.Players.PlayerAdded:Connect(function(plr) --connects a function when the playeradded event is fired
	if table.find(moderators, plr.Name) then --looks for the player's name in the moderators table
		local ui = gui:Clone() --clones the gui
		ui.Parent = plr.PlayerGui --parents the gui to the player's playerugi
		ui:FindFirstChildWhichIsA("Frame").ResetOnSpawn = false --sets the resetonspawn property to false

If you wanted to, you could swap out the string values in the “moderators” table for intvalues, and swap “plr.Name” to “plr.UserId”

1 Like

I know that this is from last year, but thanks it really worked!