commands.serverban = function(sender, arguments)
local player = findPlayer(arguments[1], sender)
if not table.find(serverBannedPlayers, player.Name) and player.Name ~= "SpySethy" then
player:Kick("you are banned from this server")
table.insert(serverBannedPlayers, player.Name)
end
end
and the :Kick() function does not seem to be kicking my friend out of the game. Can anyone help with this?
Also, as @weakroblox35 pointer out, there isn’t a direct mention to findPlayer, so that is going to be part of your issue. You can try using this update to your script, that finds the player.
commands.serverban = function(sender, arguments)
local playerName = table.concat(arguments, " ", 1)
local player = game.Players:FindFirstChild(playerName)
if player and not table.find(serverBannedPlayers, player.Name) and player.Name ~= "SpySethy" then
player:Kick("You are banned from this server")
table.insert(serverBannedPlayers, player.Name)
elseif not player then
sender:SendMessage("Player not found.")
end
end
local function findPlayer(name, sender)
if name == "me" then
return sender
else
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
end