You need to loop through the table to check if any of the values match your players name, shown below.
admins = {"metalive"}
player = game.Players.LocalPlayer
function checkWhitelist(playerName)
local whitelisted = false
for i,name in pairs(admins)do
if playerName == name then
whitelisted = true
end
end
return whitelisted
end
if checkWhitelist(player.Name) then
print("Whitelisted")
else
print("Player is not whitelisted")
end
If you want to remove the GUI before it's loaded for the player then it needs to be in a server script.
If you want to remove the GUI when the player joins then:
admins = {"metalive"}
function checkWhitelist(playerName)
local whitelisted = false
for i,name in pairs(admins)do
if playerName == name then
whitelisted = true
end
end
return whitelisted
end
game.Players.PlayerAdded:Connect(function(player)
if checkWhitelist(player.Name) then
print("Whitelisted")
else
local Ss, err = pcall(function()
local playerGui = player:WaitForChild("PlayerGui")
local gui = playerGui:WaitForChild("gui")
gui:Destroy()
end)
if Ss then
print("Gui removed")
else
warn(err)
end
end
end)
2 comments
How would I do that?
I have a question for you, is there a way I can se this to make it into a server script where it cant be effected by exploiters?