Give tool to player if in table

so i want to give players who are on my list a weapon but it doesnt work

local Allowed = {"Tunnells","TTm_pro","OFFICIAL_HACK1","beast29man","amazing40078"}
local Tool = game.ServerStorage.BanHammer:Clone()
local Player = game.Players

for _,v in ipairs(Allowed) do
    if Player.Name == v then 
        Tool.Parent = Player.Backpack
    end
end

1 Like

You’re trying to use .Name on the Players service, it’s just going to compare Players with the names allowed, You need to put this in a PlayerAdded to get the player to compare. Also you need to do the cloning in the loop because you only cloned once.

And a recommendation but you should also clone to the StarterGear so they keep the tool on respawn. And it would also be better to use UserIds instead of usernames in the event one of the allowed people change their username

This is how it has to be done (Regualr script in ServerScriptService

local Allowed = {"Tunnells","TTm_pro","OFFICIAL_HACK1","beast29man","amazing40078"}
local Tool = game.ServerStorage.BanHammer
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	for _,v in ipairs(Allowed) do
		if plr.Name == v then 
			Tool:Clone().Parent = Player.Backpack
			Tool:Clone().Parent = Player.StarterGear
			break
		end
	end
end)