Your statement returns an error because player in player.Name is not defined. You probably meant playa.Name.
Also, format your code in an organized manner!
print'Player Kicker'
admins = {"ProjectRosploit","AlexTheOtaku","Lisforlucas","Ray5069"}
game.Players.PlayerAdded:connect(function(playa)
function tableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
if playa and TableContains(admins, playa.Name) then
end
end
end)
The issue seems to be located in the function itself.
Let's make the function a static one.
print'Player Kicker'
admins = {"ProjectRosploit","AlexTheOtaku","Lisforlucas","Ray5069"}
function tableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end
game.Players.PlayerAdded:connect(function(playa)
if playa and TableContains(admins, playa.Name) then
end
end)
Now we're getting somewhere!
Now, for your GUI, I assume it's already in game.StarterGui. So, let's define it.
print'Player Kicker'
admins = {"ProjectRosploit","AlexTheOtaku","Lisforlucas","Ray5069"}
function tableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end
game.Players.PlayerAdded:connect(function(playa)
if playa then
local PlayerGui = playa:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("ScreenGui")
local Frame = Gui:WaitForChild("Frame")
if TableContains(admins, playa.Name) then
Frame.Visible = false
else
Frame.Visible = true
end
end
end)
Since game.StarterGui replicates its children to the Player's PlayerGui, the GUIs will be visible to the people in the list. So let's wrap the "if" statement with a .CharacterAdded event.
print'Player Kicker'
admins = {"ProjectRosploit","AlexTheOtaku","Lisforlucas","Ray5069"}
function tableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end
game.Players.PlayerAdded:connect(function(playa)
playa.CharacterAdded:connect(function(Character)
local PlayerGui = playa:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("ScreenGui")
local Frame = Gui:WaitForChild("Frame")
if TableContains(admins, playa.Name) then
Frame.Visible = false
else
Frame.Visible = true
end
end)
end)
1 comment
If value is a player do value.Name