Blacklist script doesn't work

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a blacklist script that takes data from github and kick any players with the id.
  2. What is the issue? Include screenshots / videos if possible!
    The script simply doesn’t work.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did, but I haven’t found the solution so far.

Here’s the code:

local url = ""
local blk = {}
local HTTP = game:GetService("HttpService")

function req()
	local s, r = pcall(function()
		return HTTP:GetAsync(url)
	end)
	return s, r
end

function spl(t, tbl)
	for w in string.gmatch(t, "([^,]+)") do
		local num = tonumber(w)
		if num then
			table.insert(tbl, num)
		else
			warn("Invalid user ID found:", w)
		end
	end
end



local s, r = req()

if s then
	print("Fetched data:", r)
	spl(r, blk)
else
	warn("Failed to retrieve text from GitHub:", r)
	return
end

game.Players.PlayerAdded:Connect(function(player)
	for _, playerID in pairs(blk) do
		if player.UserId == playerID then
			player:Kick("You are blacklisted!")
			return
		end
	end
end)

Would appreciate the help!

1 Like

The response back will be JSON encoded. You will need to decode and split the data out into a table of user IDs to check against I would expect.

Might be that the request is taking some time to complete, so PlayerAdded never actually fires because the player already exists in the server by the time github actually does send you a response (if you’re testing this solo with a blacklisted account, this is probably what’s causing the issue)? To fix that you should also run the same function you have in PlayerAdded on each player already in the game.

local Players = game:GetService("Players")

local function checkBlacklist(player)
	for _, playerID in ipairs(blk) do
		if player.UserId == playerID then
			player:Kick("You are blacklisted!")
			return
		end
	end
end

Players.PlayerAdded:Connect(checkBlacklist)
for _, player in ipairs(Players:GetPlayers()) do
	checkBlacklist(player)
end