I’m making a button for admins only and when I run this script in a “server” script nothing happens tried with the local script nothing. Does anybody know why?
allowed = {"V33S"}
game.Players.PlayerAdded:Connect(function(plr)
if table.find(allowed, plr.Name) then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end)
Firstly, use userId. Also, is this in a LocalScript? If so, whos? If its the connecting player, its not running yet.
Secondly, do NOT store the admin gui in the PlayerGui or starter gui. Especially if its functional. You are just begging exploiters to take advantage of it that way. Put the gui in ServerStorage, and in a server script, run:
local allowed = {"ID of admin"}
game.Players.PlayerAdded:Connect(function(plr)
if table.find(allowed, plr.UserId) then
local gui = game.ServerStorage.ADMINGUINAME:Clone();
gui.Parent = plr.PlayerGui;
--Make sure the property of the screenGUI in question, ResetOnDeath is set to false so it doesn't get deleted
end
end)
local allowed = {561213643} -- your userId
local plr = game:GetService("Players").LocalPlayer
if table.find(allowed, plr.UserId) then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
Make sure this is a local script. Also, if this is some admin thing, PLEASE DO SERVER SIDED CHECKS.