How to make tool not kick people if there name is in a list?

So i have a tool that kicks players but i dont want it too kick players in a list i have

local Tool = script.Parent
local Allowed = {"Tunnells","OFFICIAL_HACK1","beast29man","amazing40078","Player1"}
local Module = require(Tool:WaitForChild("Setting"))
local can, onAnimation = true, false

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..Module.IdleAnimationID
end
if Module.HitAnimationID ~= nil then
	local HitAnim = Instance.new("Animation",Tool)
	HitAnim.Name = "HitAnim"
	HitAnim.AnimationId = "rbxassetid://"..Module.HitAnimationID
end
local Players = game:GetService("Players")
function unEquipItems() script.Parent.Parent = Players:GetPlayerFromCharacter(script.Parent.Parent).Backpack end

script.Damage.OnServerEvent:Connect(function(plr,tipe)
	if tipe then
		if tipe == 0 then
			onAnimation = true
		else
			onAnimation = false
		end
	end
end)

script.Parent.Handle.Touched:Connect(function(hit)
	local Players = game:GetService("Players")
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= script.Parent.Parent.Name and hit.Parent.Humanoid.Health > 0 and can and onAnimation then
		can = false 


		local TargetPlayer = Players:GetPlayerFromCharacter(hit.Parent)

		if TargetPlayer then
			for _,v in pairs(Allowed) do
				if TargetPlayer.Name == v then
					print("NO LOL")
				else
					







				TargetPlayer:Kick("You have been hit by a overpowered weapon O_O")
					spawn(function() wait(.5) can = true end)
				
			end
		end
	end
end)
while wait(.1) do 
	if script.Parent.Parent.Name ~= "Backpack" and script.Parent.Parent:FindFirstChild("Humanoid") and script.Parent.Parent.Humanoid.Sit == true then unEquipItems() end 
end
```

Try this:

Im guessing that allowed is people that can’t get kicked by the tool.

local Tool = script.Parent
local Allowed = {"Tunnells","OFFICIAL_HACK1","beast29man","amazing40078","Player1"}
local Module = require(Tool:WaitForChild("Setting"))
local can, onAnimation = true, false

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..Module.IdleAnimationID
end
if Module.HitAnimationID ~= nil then
	local HitAnim = Instance.new("Animation",Tool)
	HitAnim.Name = "HitAnim"
	HitAnim.AnimationId = "rbxassetid://"..Module.HitAnimationID
end
local Players = game:GetService("Players")
function unEquipItems() script.Parent.Parent = Players:GetPlayerFromCharacter(script.Parent.Parent).Backpack end

script.Damage.OnServerEvent:Connect(function(plr,tipe)
	if tipe then
		if tipe == 0 then
			onAnimation = true
		else
			onAnimation = false
		end
	end
end)

script.Parent.Handle.Touched:Connect(function(hit)
	local Players = game:GetService("Players")
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= script.Parent.Parent.Name and hit.Parent.Humanoid.Health > 0 and can and onAnimation then
		can = false 
		
		local TargetPlayer = Players:GetPlayerFromCharacter(hit.Parent)
		if not table.find(Allowed,TargetPlayer.Name) then
			TargetPlayer:Kick("You have been hit by a overpowered weapon O_O")
		end
		end
	end)
while wait(.1) do 
	if script.Parent.Parent.Name ~= "Backpack" and script.Parent.Parent:FindFirstChild("Humanoid") and script.Parent.Parent.Humanoid.Sit == true then unEquipItems() end 
end

This doesnt work lol it doesnt kick admins

You can get the table of admin, that’s what your list is I assume, so for example
local playersToNotKick = {1,2,3,4}
(use UserIds of the players so if they change their name it won’t break)
Then you can use table.find to check if there’s a player in the list.

if not table.find(playersToNotKick,TargetPlayer.UserId) then
      TargetPlayer:Kick("ha get kicked")
end

basically that says, if the script can’t find the player’s userid in the list of userids not to kick, then you can kick them!

local Tool = script.Parent
local Allowed = {"Tunnells","OFFICIAL_HACK1","beast29man","amazing40078","Player1"}
local Module = require(Tool:WaitForChild("Setting"))
local can, onAnimation = true, false

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..Module.IdleAnimationID
end
if Module.HitAnimationID ~= nil then
	local HitAnim = Instance.new("Animation",Tool)
	HitAnim.Name = "HitAnim"
	HitAnim.AnimationId = "rbxassetid://"..Module.HitAnimationID
end
local Players = game:GetService("Players")
function unEquipItems() script.Parent.Parent = Players:GetPlayerFromCharacter(script.Parent.Parent).Backpack end

script.Damage.OnServerEvent:Connect(function(plr,tipe)
	if tipe then
		if tipe == 0 then
			onAnimation = true
		else
			onAnimation = false
		end
	end
end)

script.Parent.Handle.Touched:Connect(function(hit)
	local Players = game:GetService("Players")
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= script.Parent.Parent.Name and hit.Parent.Humanoid.Health > 0 and can and onAnimation then
		can = false 
		
		local TargetPlayer = Players:GetPlayerFromCharacter(hit.Parent)
		if not table.find(Allowed,TargetPlayer.Name) then
			TargetPlayer:Kick("You have been hit by a overpowered weapon O_O")
		end
		end
	end)
while wait(.1) do 
	if script.Parent.Parent.Name ~= "Backpack" and script.Parent.Parent:FindFirstChild("Humanoid") and script.Parent.Parent.Humanoid.Sit == true then unEquipItems() end 
end
``` i know i will one day change it too userids xd but this doesnt work

Im confused. Is the allowed table people who can or can’t be kicked.

Should not be kicked lol then other players who arent in the table shouldnt be kicked

I would loop through the Players list in server, then make a separate array and use table.insert() to add that player to the array let’s call it “NoKickArray” and then after the loop is done, you would loop through players again and if their name is found in NoKickArray (loop through this array for every player) then DO NOT kick.

That’s weird, are you sure you committed the scripts? I might have to test this myself, but I don’t see what’s wrong with it.

I will say some of your indentation is odd, so maybe make sure all of the nested statements are correct.

The script works but it only works once…

You never set can to true, so it won’t run again. Did you mean to use that as a debounce? Set it back to true after a wait(1) or something.