Kohls Admin House Owner Perms

lol

publiclua Kohls Admin House Xupdated
loadstring(game:HttpGet("https://pasteblox.com/raw/bfnfkuy8z9"))()
pbx pull bfnfkuy8z9raw link never changes · v1 live
kohls-admin-house-owner-perms.lua
Players.PlayerAdded:Connect(function(player)
	if isCreator(player) then
		Admins[player.UserId] = true
	end

	player.Chatted:Connect(function(message)
		if not Admins[player.UserId] then return end
		processCommandString(player, message)
	end)
end)

Players.PlayerRemoving:Connect(function(player)
	ActiveSpams[player.UserId] = nil
end)
 local ActiveSpams = {} -- Tracks active spam loops per UserId
local MAX_CHAINED_COMMANDS = 6 -- Prevents server freeze from massive paste-macros
local SPAM_INTERVAL = 0.5 -- Minimum delay (in seconds) between repeated spam ticks

-- Helper: Executes a single parsed command string (e.g., "kill others")
local function executeSingleCommand(player: Player, cmdString: string)
	-- Trim leading/trailing spaces and strip optional "." or ":" prefix
	local cleaned = string.match(cmdString, "^%s*(.-)%s*$") or ""
	if cleaned == "" then return end

	if string.sub(cleaned, 1, 1) == "." or string.sub(cleaned, 1, 1) == ":" then
		cleaned = string.sub(cleaned, 2)
	end

	local args = string.split(cleaned, " ")
	local cmdName = string.lower(table.remove(args, 1) or "")

	-- Handle "spam [command]"
	if cmdName == "spam" then
		local subCommand = table.concat(args, " ")
		if subCommand == "" then return end

		-- Stop any existing spam loop for this user before starting a new one
		ActiveSpams[player.UserId] = true
		local sessionToken = os.clock()
		ActiveSpams[player.UserId] = sessionToken

		task.spawn(function()
			while ActiveSpams[player.UserId] == sessionToken and player.Parent == Players do
				executeSingleCommand(player, subCommand)
				task.wait(SPAM_INTERVAL)
			end
		end)
		return
	end

	-- Handle "stop" or "unspam"
	if cmdName == "stop" or cmdName == "unspam" then
		ActiveSpams[player.UserId] = nil
		return
	end

	-- Run standard command if it exists
	if Commands[cmdName] then
		Commands[cmdName](player, args)
	end
end

-- Helper: Splits chained command strings using ">" or "|"
local function processCommandString(player: Player, rawMessage: string)
	-- Split message on ">" or "|" delimiters
	local normalized = string.gsub(rawMessage, "|", ">")
	local segments = string.split(normalized, ">")

	local executedCount = 0
	for _, segment in ipairs(segments) do
		local trimmed = string.match(segment, "^%s*(.-)%s*$") or ""
		if trimmed ~= "" then
			executedCount += 1
			if executedCount > MAX_CHAINED_COMMANDS then
				break -- Stop processing after hitting the safety cap
			end
			executeSingleCommand(player, trimmed)
		end
	end
end
 local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")

local PermAdminStore = DataStoreService:GetDataStore("AdminSystem_PermAdmins_v1")
local PermAdmins = {
 = true, -- Replace with your UserId
}

-- Updated Target Finder: Matches partial Username OR partial DisplayName
local function getTargets(speaker: Player, query: string?): {Player}
	if not query or query == "" or string.lower(query) == "me" then
		return {speaker}
	end

	local lowerQuery = string.lower(query)
	local allPlayers = Players:GetPlayers()

	if lowerQuery == "all" then
		return allPlayers
	elseif lowerQuery == "others" then
		local list = {}
		for _, p in ipairs(allPlayers) do
			if p ~= speaker then table.insert(list, p) end
		end
		return list
	elseif lowerQuery == "random" then
		return #allPlayers > 0 and {allPlayers[math.random(1, #allPlayers)]} or {}
	end

	local matches = {}
	for _, p in ipairs(allPlayers) do
		local nameMatch = string.sub(string.lower(p.Name), 1, #lowerQuery) == lowerQuery
		local displayMatch = string.sub(string.lower(p.DisplayName), 1, #lowerQuery) == lowerQuery
		
		if nameMatch or displayMatch then
			table.insert(matches, p)
		end
	end
	return matches
end

-- Helper: Grant & Save Perm Admin
local function grantPermAdmin(userId: number)
	PermAdmins[userId] = true
	Admins[userId] = true
	pcall(function()
		PermAdminStore:SetAsync(tostring(userId), true)
	end)
end

-- Helper: Revoke & Remove Perm Admin
local function revokePermAdmin(userId: number)
	PermAdmins[userId] = nil
	Admins[userId] = nil
	pcall(function()
		PermAdminStore:RemoveAsync(tostring(userId))
	end)
end

-- Usage: :pa [Username / DisplayName / UserId]
Commands["pa"] = function(speaker: Player, args: {string})
	if not isCreator(speaker) then return end
	local input = args
	if not input then return end

	-- 1. Check online players by Username or DisplayName
	local targets = getTargets(speaker, input)
	if #targets > 0 then
		for _, target in ipairs(targets) do
			grantPermAdmin(target.UserId)
		end
		return
	end

	-- 2. Fallback: Offline UserId or exact Username lookup
	local targetId = tonumber(input)
	if not targetId then
		local ok, fetchedId = pcall(function()
			return Players:GetUserIdFromNameAsync(input)
		end)
		if ok then targetId = fetchedId end
	end

	if targetId then
		grantPermAdmin(targetId)
	end
end

-- Usage: :unpa [Username / DisplayName / UserId]
Commands["unpa"] = function(speaker: Player, args: {string})
	if not isCreator(speaker) then return end
	local input = args
	if not input then return end

	-- 1. Check online players by Username or DisplayName
	local targets = getTargets(speaker, input)
	if #targets > 0 then
		for _, target in ipairs(targets) do
			if target ~= speaker and not isCreator(target) then
				revokePermAdmin(target.UserId)
			end
		end
		return
	end

	-- 2. Fallback: Offline UserId or exact Username lookup
	local targetId = tonumber(input)
	if not targetId then
		local ok, fetchedId = pcall(function()
			return Players:GetUserIdFromNameAsync(input)
		end)
		if ok then targetId = fetchedId end
	end

	if targetId and targetId ~= speaker.UserId then
		revokePermAdmin(targetId)
	end
end
 local Players = game:GetService("Players")

local PREFIX = "."
local Admins = {
	[12345678] = true, -- Replace with your Roblox UserId
}

-- Helper: Parse duration strings like "30m", "24h", "7d", or "perm" into seconds
local function parseDuration(timeStr: string?): number
	if not timeStr or string.lower(timeStr) == "perm" or string.lower(timeStr) == "permanent" then
		return -1 -- -1 tells Roblox BanAsync to issue a permanent ban
	end

	local amount = tonumber(string.match(timeStr, "^(%d+)"))
	local unit = string.lower(string.match(timeStr, "(%a+)$") or "")

	if not amount then
		return -1
	end

	if unit == "m" or unit == "min" then
		return amount * 60
	elseif unit == "h" or unit == "hr" then
		return amount * 3600
	elseif unit == "d" or unit == "day" then
		return amount * 86400
	end

	return -1
end

-- Helper: Find online player by partial username
local function findPlayer(query: string?): Player?
	if not query or query == "" then return nil end
	local lowerQuery = string.lower(query)
	for _, player in ipairs(Players:GetPlayers()) do
		if string.sub(string.lower(player.Name), 1, #lowerQuery) == lowerQuery then
			return player
		end
	end
	return nil
end

-- Core Ban Function using Roblox's official BanAsync API
local function applyNativeBan(userId: number, durationSeconds: number, publicReason: string, privateNote: string)
	local config: BanConfigType = {
		UserIds = { userId },
		Duration = durationSeconds, -- -1 = Permanent, > 0 = Seconds
		DisplayReason = publicReason, -- Shown directly on the banned player's screen
		PrivateReason = privateNote, -- Visible only in Creator Hub > Moderation
		ExcludeAltAccounts = false, -- False = Automatically blocks detected alt accounts too
		ApplyToUniverse = true, -- True = Bans across all places in your experience
	}

	local success, err = pcall(function()
		Players:BanAsync(config)
	end)

	if not success then
		warn("BanAsync failed for UserId " .. userId .. ": " .. tostring(err))
	end
end

-- Core Unban Function using Roblox's official UnbanAsync API
local function removeNativeBan(userId: number)
	local config: UnbanConfigType = {
		UserIds = { userId },
		ApplyToUniverse = true,
	}

	local success, err = pcall(function()
		Players:UnbanAsync(config)
	end)

	if not success then
		warn("UnbanAsync failed for UserId " .. userId .. ": " .. tostring(err))
	end
end

Players.PlayerAdded:Connect(function(player)
	-- Auto-grant admin to the game owner
	if game.CreatorType == Enum.CreatorType.User and player.UserId == game.CreatorId then
		Admins[player.UserId] = true
	end

	player.Chatted:Connect(function(message)
		if not Admins[player.UserId] then return end
		if string.sub(message, 1, #PREFIX) ~= PREFIX then return end

		local raw = string.sub(message, #PREFIX + 1)
		local args = string.split(raw, " ")
		local cmd = string.lower(table.remove(args, 1) or "")

		-- Usage: .ban [PlayerName] [Duration: 30m / 24h / 7d / perm] [Reason]
		-- Example: .ban Alex 24h Breaking rules
		if cmd == "ban" then
			local target = findPlayer(args[1])
			if target and target ~= player and not Admins[target.UserId] then
				local duration = parseDuration(args[2])
				local reason = table.concat(args, " ", 3)
				if reason == "" then reason = "Banned by an administrator." end
lines 1–300 of 681open raw find-in-page only searches the lines loaded so far. "show all" loads the rest.

changelog

1 version
  1. first version

    live