How to make a GUI visible to only certain players

Hello!
Ok, I know I should have probably figured this out, but for some reason, no matter what I try, it doesn’t work. I made a admin panel in my game, and I want only certain players to see it.

I’ve only been able to allow one viewer of the GUI, and it is not even myself. I changed it to the youtuber who played my game. I’m not getting any errors, (which kind of makes sense) but anyway here are some screenshots and the Lua.
image
The Local Script under “ADMIN” contains this Lua:

if game.Players.LocalPlayer.Name == "example" then
	
else
	script.Parent.Enabled = false
end

Keep in mind this works for one player. I want it to work for as many as I want.

Any help appreciated!

create a table full of the userids of the admins userid, So when they change their usernames, it would still work, then use table.find if the localplayers userid is in the admins table

if it doesn’t find it, then just remove it

local Admins = {1638409266}

if table.find(Admins, game:GetService("Players").LocalPlayer.UserId) then
	script.Parent.Enabled = true
else
	script.Parent:Destroy()
end
1 Like

Place the GUI in ReplicatedStorage and make a ServerScript in ServerScriptService which contains this script

game:GetService("Players").PlayerAdded:Connect(function(Player)
	if Player.Name == "example" then 
		local UI = game:GetService("ReplicatedStorage").ADMIN:Clone()
		UI.Parent = Player.PlayerGui
	else 
		return 
	end
end)

its not recommended to script an admin panel with local scripts because exploiters can easily just set the admin panels Enabled property to true

1 Like

So the Destroy function would work because it’s local you’re saying. Thanks!

This works too, but I just used pings method. tysm anyway! :smiley: