有没有办法检查一个数组的任何内容是否在 Roblox 的另一个数组中

Is there a way to check if any content of a array is in another array in Roblox

所以我正在尝试制作一个允许我禁止他人的脚本,但检查玩家是否在游戏中的主要脚本 在被禁止的用户列表中是被杀或被踢。这是我的代码:

local BannedUsers = {"littleBitsman"}
local Players = game.Players:GetChildren()
wait(10)
for index1,value1 in ipairs(Players) do
    for index2,value2 in ipairs(BannedUsers) do
        if Players[index1] == BannedUsers[tonumber(index2)] then
            local HumanoidToKill = workspace[value1].Character:FindFirstChildWhichIsA("Humanoid")
            if HumanoidToKill.Health >= 0 then
                HumanoidToKill.Health = 0
                print("killed " .. tostring(value1))
            end
        end
    end
end

wait(10) 这样我就可以测试脚本而不会太早执行,我的用户名用于测试。 另外,当我测试它时,它什么也没做。

您可以使用table.find函数。

local BannedUsers = {"littleBitsman"}

for _, player in ipairs(game.Players:GetChildren()) do
     if table.find(BannedUsers, player.Name) then
          player:Kick("You are banned!")
     end
end