AntiRaidAntiRaid

Examples

Ready-to-use Luau CAPTCHA templates you can copy and customize.

Updated April 11, 2026

Basic CAPTCHA

A simple image CAPTCHA with noise, wave distortion, a grid, a line, color inversion, and random lines. Good starting point for most servers.

local interop = require "@antiraid/interop"
local img_captcha = require "@antiraid/img_captcha"

local captcha_config = {}

captcha_config.char_count = 7
captcha_config.viewbox_size = setmetatable({ 280, 160 }, interop.array_metatable)
captcha_config.filters = setmetatable({}, interop.array_metatable)

table.insert(captcha_config.filters, { filter = "Noise", prob = 0.05 })
table.insert(captcha_config.filters, { filter = "Wave", f = 4.0, amp = 20.0, d = "horizontal" })
table.insert(captcha_config.filters, { filter = "Grid", x_gap = 10, y_gap = 30 })
table.insert(captcha_config.filters, {
    filter = "Line",
    p1 = setmetatable({ 0.0, 0.0 }, interop.array_metatable),
    p2 = setmetatable({ 30.0, 100.0 }, interop.array_metatable),
    thickness = 7.0,
    color = setmetatable({ 0, 0, 0 }, interop.array_metatable)
})
table.insert(captcha_config.filters, { filter = "ColorInvert" })
table.insert(captcha_config.filters, { filter = "RandomLine" })

return img_captcha.new(captcha_config)

CAPTCHA with increasing difficulty and attempt limit

This template increases the character count with each failed attempt and blocks the user after 5 tries within the session window.

local interop = require "@antiraid/interop"
local img_captcha = require "@antiraid/img_captcha"

-- Initialize attempt tracking
if __stack._captcha_user_tries == nil then
    __stack._captcha_user_tries = {}
end
if __stack._captcha_user_tries[args.user.id] == nil then
    __stack._captcha_user_tries[args.user.id] = 0
end

-- Block after 5 attempts
if __stack._captcha_user_tries[args.user.id] >= 5 then
    error("You have reached the maximum number of tries in this 5 minute window.")
end

local captcha_config = {}

-- Increase character count with each attempt (7 → up to 10)
captcha_config.char_count = math.min(7 + __stack._captcha_user_tries[args.user.id], 10)
captcha_config.viewbox_size = setmetatable({ 280, 160 }, interop.array_metatable)
captcha_config.filters = setmetatable({}, interop.array_metatable)

-- Increment attempt counter
__stack._captcha_user_tries[args.user.id] += 1

return img_captcha.new(captcha_config)