I’m trying to make a developer-side moderation tool, and I keep getting stuck on this one thing. i am trying to make a script that pulls from a Pastebin database in the layout of this, JSON: 1. [301810204, 301819935, 123123123, 408312701,2775060166,17578965036] for example (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. I made a similar system for group and player blacklist and it is working fine.
Here is what I have so far, but I can’t get it to work.
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
-- Split the response by commas and convert to numbers
local bannedAssets = {}
for _, id in pairs(string.split(response, ",")) do
table.insert(bannedAssets, tonumber(id))
end
print("Banned assets fetched successfully")
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 humanoid = player.Character:WaitForChild("Humanoid")
local humanoidDescription = humanoid:WaitForChild("HumanoidDescription")
-- Function to check accessories
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
-- Check all accessory types
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
-- Check clothing types
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)
Here is the group blacklist for example:
-- Pastebin raw URL
local pastebinURL = "raw/AYMv6NiN" -- 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 groupId
end
end
return nil
end
-- Function to handle player joining
local function onPlayerAdded(player)
local bannedGroups = fetchBannedGroups()
local bannedGroupId = isInBannedGroup(player, bannedGroups)
if bannedGroupId then
player:Kick("You are in a banned group (Group ID: " .. tostring(bannedGroupId) .. ").")
end
end
-- Connect the function to the PlayerAdded event
game.Players.PlayerAdded:Connect(onPlayerAdded)
type or paste code here