How would I make an auto kick script if you have a blacklisted item on?

I’m trying to make a developer side moderation tool and i keep geting stuk on this one thing. i am trying to make a script that pulls from a Pastebin database in the layout of this 00000,000000 (id’s added one after another in a list) that will automatically kick a player from the game if the avatar item is a match on the list.

Here is what I have so far but cant get it to work.

local HttpService = game:GetService(“HttpService”)

– Pastebin raw URL
local pastebinURL = “link” – replace with your actual Pastebin raw URL

– Function to fetch banned asset IDs from Pastebin
local function fetchBannedAssets()
local success, response = pcall(function()
return HttpService:GetAsync(pastebinURL)
end)

if success then
	local bannedAssets = {}
	for assetId in string.gmatch(response, "%d+") do
		table.insert(bannedAssets, tonumber(assetId))
	end
	return bannedAssets
else
	warn("Failed to fetch banned assets: " .. tostring(response))
	return {}
end

end

– Function to check if a player is wearing any of the banned assets
local function isWearingBannedAsset(player, bannedAssets)
local humanoidDescription = player.Character:WaitForChild(“Humanoid”).HumanoidDescription

local function checkAccessories(accessoryIds)
	for _, assetId in pairs(bannedAssets) do
		for _, id in pairs(accessoryIds) do
			if tonumber(id) == assetId then
				return true
			end
		end
	end
	return false
end

local accessoryTypes = {
	humanoidDescription.HatAccessory,
	humanoidDescription.FaceAccessory,
	humanoidDescription.NeckAccessory,
	humanoidDescription.ShouldersAccessory,
	humanoidDescription.FrontAccessory,
	humanoidDescription.BackAccessory,
	humanoidDescription.WaistAccessory
	
}

for _, accessory in pairs(accessoryTypes) do
	if checkAccessories(string.split(accessory, ",")) then
		return true
	end
end

local clothingTypes = {
	humanoidDescription.Shirt,
	humanoidDescription.Pants,
	humanoidDescription.ShirtGraphic
}

for _, clothing in pairs(clothingTypes) do
	for _, assetId in pairs(bannedAssets) do
		if tonumber(clothing) == assetId then
			return true
		end
	end
end

return false

end

– Function to handle player joining
local function onPlayerAdded(player)
player.CharacterAdded:Connect(function(character)
– Wait for the character to be fully loaded
character:WaitForChild(“Humanoid”)
character:WaitForChild(“HumanoidDescription”)

	local bannedAssets = fetchBannedAssets()
	if isWearingBannedAsset(player, bannedAssets) then
		player:Kick("You are wearing a restricted item.")
	end
end)

end

– Connect the function to the PlayerAdded event
game.Players.PlayerAdded:Connect(onPlayerAdded)

I got this working for backlisted player and groups. here is an example for the group band script

local HttpService = game:GetService(“HttpService”)

– Pastebin raw URL
local pastebinURL = “link” – replace with your actual Pastebin raw URL

– Function to fetch banned group IDs from Pastebin
local function fetchBannedGroups()
local success, response = pcall(function()
return HttpService:GetAsync(pastebinURL)
end)

if success then
	local bannedGroups = {}
	for groupId in string.gmatch(response, "%d+") do
		table.insert(bannedGroups, tonumber(groupId))
	end
	return bannedGroups
else
	warn("Failed to fetch banned groups: " .. tostring(response))
	return {}
end

end

– Function to check if a player is in any of the banned groups
local function isInBannedGroup(player, bannedGroups)
for _, groupId in pairs(bannedGroups) do
if player:IsInGroup(groupId) then
return true
end
end
return false
end

– Function to handle player joining
local function onPlayerAdded(player)
local bannedGroups = fetchBannedGroups()
if isInBannedGroup(player, bannedGroups) then
player:Kick(“You are in a banned group.”)
end
end

– Connect the function to the PlayerAdded event
game.Players.PlayerAdded:Connect(onPlayerAdded)

any ideas on how to fix it

Uh, should there be an actual url there instead of a placeholder? You also need to use HttpService:JSONDecode afterward otherwise Roblox scripts will not be able to read the data. You should probably look at the data in a new tab (with the link pasted in at the top) as well to see the structure that you are dealing with because sometimes with APIs you have to go through multiple layers of nothing to get to that data. Good luck!

local HttpService = game:GetService(“HttpService”)
local Players = game:GetService(“Players”)

– Pastebin raw URL
local pastebinURL = “raw/x8e62ZBp” – replace with your actual Pastebin raw URL

– Function to fetch banned asset IDs from Pastebin
local function fetchBannedAssets()
print(“Fetching banned assets…”)
local success, response = pcall(function()
return HttpService:GetAsync(pastebinURL)
end)

if success then
	local bannedAssets = HttpService:JSONDecode(response)
	print("Banned assets fetched successfully: ", bannedAssets)
	return bannedAssets
else
	warn("Failed to fetch banned assets: " .. tostring(response))
	return {}
end

end

– Function to check if a player is wearing any of the banned assets
local function isWearingBannedAsset(player, bannedAssets)
local humanoidDescription = player.Character:WaitForChild(“Humanoid”).HumanoidDescription

local function checkAccessories(accessoryIds)
	for _, assetId in pairs(bannedAssets) do
		for _, id in pairs(accessoryIds) do
			if tonumber(id) == assetId then
				return true
			end
		end
	end
	return false
end

local accessoryTypes = {
	humanoidDescription.HatAccessory,
	humanoidDescription.FaceAccessory,
	humanoidDescription.NeckAccessory,
	humanoidDescription.ShouldersAccessory,
	humanoidDescription.FrontAccessory,
	humanoidDescription.BackAccessory,
	humanoidDescription.WaistAccessory
}

for _, accessory in pairs(accessoryTypes) do
	if checkAccessories(string.split(accessory, ",")) then
		return true
	end
end

local clothingTypes = {
	humanoidDescription.Shirt,
	humanoidDescription.Pants,
	humanoidDescription.ShirtGraphic
}

for _, clothing in pairs(clothingTypes) do
	for _, assetId in pairs(bannedAssets) do
		if tonumber(clothing) == assetId then
			return true
		end
	end
end

return false

end

– Function to handle player joining
local function onPlayerAdded(player)
print("Player added: ", player.Name)
player.CharacterAdded:Connect(function(character)
– Wait for the character to be fully loaded
character:WaitForChild(“Humanoid”)
character:WaitForChild(“HumanoidDescription”)

	-- Adding a delay to ensure the character is fully loaded
	wait(5)

	local bannedAssets = fetchBannedAssets()
	if isWearingBannedAsset(player, bannedAssets) then
		print("Player " .. player.Name .. " is wearing a banned item.")
		player:Kick("You are wearing a restricted item.")
	else
		print("Player " .. player.Name .. " is not wearing any banned items.")
	end
end)

end

– Connect the function to the PlayerAdded event
Players.PlayerAdded:Connect(onPlayerAdded)

full script. was giving me errors with the link. still having problems of it not detecting

What errors were you getting? Can you show me them? I might be able to help if you do.

the problem is, there is no error that shows up in the console.

here is a copy of the pastebin [301810204, 301819935, 123123123, 408312701,2775060166] (roblox wont allow me to post the link).

If you put the link into your url box in your browser do you get the expected data on a plain white page? If so your link is correct, otherwise if it takes you to a website it is invalid. You could also remove the pcall around the GetAsync so it does give you an error, then you will get more of an idea what’s going wrong.

You should also make sure the script is triggering in the first place by adding prints if your log is completely empty right now.