I'm trying to make a for loop and it goes through and prints my error. I matched the players name and the text in the textbox and still does the print. There are no errors in output.
local list = {[101897600] = true}
game.Players.PlayerAdded:Connect(function(plr)
if list[plr.UserId] then
local adminPanel = script.AdminPanel
adminPanel.Parent = plr.PlayerGui
end
local remoteFunction1 = Instance.new("RemoteEvent",plr)
remoteFunction1.OnServerEvent:Connect(function()
findPlayer()
end)
end)
function findPlayer()
for _,v in pairs(game.Players:GetPlayers()) do
local plrName = v
local gui = plrName.PlayerGui:FindFirstChild('AdminPanel')
if gui.MainFrame.PlayerName.Text == v.Name then
v:Kick('Kicked by an Admin')
elseif gui.MainFrame.PlayerName.Text ~= v then
print('Error')
end
end
end

4 comments
Is this a Server Script? If it is, it cannot read or change items in the PlayerGui
It is a server script with the gui inside of it. It clones into the PlayerGui.
you are trying to use a function that you declare later on in the script put findPlayer before the event