Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
40 views52 pages

Message

The document outlines a Lua script for a restricted admin GUI in Roblox, designed to manage player bans while adhering to Roblox's Terms of Service. It includes functionality for loading and saving permanent and timed bans, as well as a user interface for authorized players to interact with. The script features in-memory ban lists, player search capabilities, and an admin panel that is only accessible to specific usernames.

Uploaded by

rayffan.fp22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views52 pages

Message

The document outlines a Lua script for a restricted admin GUI in Roblox, designed to manage player bans while adhering to Roblox's Terms of Service. It includes functionality for loading and saving permanent and timed bans, as well as a user interface for authorized players to interact with. The script features in-memory ban lists, player search capabilities, and an admin panel that is only accessible to specific usernames.

Uploaded by

rayffan.fp22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 52

-- RestrictedAdminGUI.

lua
-- A ModuleScript with admin panel restricted to specific usernames that follows
Roblox TOS
-- Adapted Ban Logic based on BanIt by Ty_Scripts

local Players = game:GetService("Players")


local DataStoreService = game:GetService("DataStoreService")
local MessagingService = game:GetService("MessagingService")
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")

--[[ Old DataStore - Can be removed later


local BanStore = DataStoreService:GetDataStore("AdminGUITempBans")
]]

-- New DataStores based on BanIt approach


local permanentBanStore = DataStoreService:GetDataStore("CoreSigmaGlobalBans")
local timedBanStore = DataStoreService:GetDataStore("CoreSigmaTimedBans")

local BAN_MESSAGE_TOPIC = "CoreSigmaBanNotification_V2" -- Topic for


MessagingService (Changed to avoid conflicts)

local RestrictedAdminGUI = {}

-- In-memory ban lists (Adapted BanIt Style)


local loadedGlobalBans = {} -- Array of UserIDs: { 12345, 67890, ... }
local loadedTimedBans = {} -- Dictionary: { ["userIdString"] =
"timestamp;duration", ... }

-- Function to load permanent bans (as an array)


local function loadGlobalBans()
local success, data = xpcall(function()
return permanentBanStore:GetAsync("GlobalBans") -- Expecting an array
end, function(err)
warn("[CORE SIGMA] Failed to load global bans: " .. tostring(err))
return nil
end)
if success and typeof(data) == "table" then
-- Ensure it's treated as an array, even if loaded empty
loadedGlobalBans = data
local count = 0
-- Check if it looks like an array (numeric indices)
if #data > 0 or next(data) == nil then
loadedGlobalBans = data
count = #loadedGlobalBans
else
-- It might be an old dictionary format, try converting or reset
warn("[CORE SIGMA] GlobalBans data might be in old format.
Resetting to empty array.")
loadedGlobalBans = {}
end
print("[CORE SIGMA] Loaded", count, "global bans.")
else
loadedGlobalBans = {} -- Initialize as empty array if load fails or no
data
print("[CORE SIGMA] Initialized empty global ban list.")
end
end
-- Function to load timed bans (as a dictionary {userIdString =
"timestamp;duration"})
local function loadTimedBans()
local success, data = xpcall(function()
return timedBanStore:GetAsync("TimedBans") -- Expecting a dictionary
end, function(err)
warn("[CORE SIGMA] Failed to load timed bans: " .. tostring(err))
return nil
end)
if success and typeof(data) == "table" then
loadedTimedBans = data
local count = 0
for _ in pairs(loadedTimedBans) do count = count + 1 end
print("[CORE SIGMA] Loaded", count, "timed bans.")
else
loadedTimedBans = {} -- Initialize as empty dictionary if load fails or
no data
print("[CORE SIGMA] Initialized empty timed ban dictionary.")
end
end

-- Function to save permanent bans (as an array)


local function saveGlobalBans()
local success, err = xpcall(function()
permanentBanStore:SetAsync("GlobalBans", loadedGlobalBans)
print("[CORE SIGMA] Saved global bans.")
end, function(err)
warn("[CORE SIGMA] Failed to save global bans: " .. tostring(err))
end)
return success
end

-- Function to save timed bans (as a dictionary)


local function saveTimedBans()
local success, err = xpcall(function()
timedBanStore:SetAsync("TimedBans", loadedTimedBans)
print("[CORE SIGMA] Saved timed bans.")
end, function(err)
warn("[CORE SIGMA] Failed to save timed bans: " .. tostring(err))
end)
return success
end

-- Load initial data when script runs


loadGlobalBans()
loadTimedBans()

--[[ PlayerAdded connection moved inside checkBan logic for clarity


Players.PlayerAdded:Connect(function(player)
task.wait(1)
if RunService:IsStudio() then
print(string.format("[CORE SIGMA Module] Checking ban for %s (%d) on
PlayerAdded", player.Name, player.UserId))
end
local isBanned = RestrictedAdminGUI.checkBan(player)
if RunService:IsStudio() then
print(string.format("[CORE SIGMA Module] Ban check result for %s: %s",
player.Name, tostring(isBanned)))
end
end)
]]

if RunService:IsStudio() then
print("[CORE SIGMA Module] Ban check will occur via Players.PlayerAdded in a
separate script calling checkBan.")
end

-- Allowed usernames (MUST BE ALL LOWERCASE)


local allowedUsers = {
"purezanaje",
"jedilnwza",
"altaccountidontcarel"
}

-- Helper function to find a player by partial name (case-insensitive)


function RestrictedAdminGUI.findPlayer(partialName)
local lowerPartialName = partialName:lower()
local foundPlayer = nil
local potentialMatches = {}
local exactMatch = nil

-- Debug info for Studio testing


if RunService:IsStudio() then
print("Finding player with name: " .. partialName)
print("Current players in game:")
for _, p in pairs(Players:GetPlayers()) do
print(" - " .. p.Name .. " (DisplayName: " .. p.DisplayName ..
")")
end
end

-- First try exact matches (case insensitive)


for _, player in pairs(Players:GetPlayers()) do
local lowerName = player.Name:lower()
local lowerDisplayName = player.DisplayName:lower()

if lowerName == lowerPartialName or lowerDisplayName ==


lowerPartialName then
exactMatch = player
break -- Exit loop as we found an exact match
end
end

-- Return exact match if found


if exactMatch then
return exactMatch
end

-- If no exact match, try partial matches


for _, player in pairs(Players:GetPlayers()) do
local lowerName = player.Name:lower()
local lowerDisplayName = player.DisplayName:lower()

-- Check for substring match


if string.find(lowerName, lowerPartialName) or
string.find(lowerDisplayName, lowerPartialName) then
table.insert(potentialMatches, player)
end
end

if #potentialMatches == 1 then
return potentialMatches[1] -- Only one partial match found
elseif #potentialMatches > 1 then
return potentialMatches -- Return table of multiple matches
end

return nil -- No player found


end

-- Create an alternative entry point with an obscure name


function RestrictedAdminGUI.letskibiditime(usernameOrPlayer)
return RestrictedAdminGUI.showPanel(usernameOrPlayer)
end

-- Function to create and display the admin GUI


function RestrictedAdminGUI.showPanel(usernameOrPlayer)
local player
local username

if typeof(usernameOrPlayer) == "Instance" and usernameOrPlayer:IsA("Player")


then
player = usernameOrPlayer
username = player.Name
elseif typeof(usernameOrPlayer) == "string" then
username = usernameOrPlayer
player = Players:FindFirstChild(username)
if not player then
-- Don't log this to avoid revealing the script
return -- Cannot open panel if player doesn't exist
end
else
-- Don't log this to avoid revealing the script
return
end

-- Special case for known admin with capitalization issues (if your username
is AltAccountIdontcareL)
if username:lower() == "altaccountidontcarel" then
-- Debug info for Studio testing
if RunService:IsStudio() then
print("Special case handling for AltAccountIdontcareL")
end
-- Continue with admin access
-- Check authorization - silently fail for non-whitelisted users
elseif not table.find(allowedUsers, username:lower()) then
-- Debug info for Studio testing
if RunService:IsStudio() then
print("Access denied for user: " .. username)
print("Allowed users:")
for i, allowedUser in ipairs(allowedUsers) do
print(" " .. i .. ": " .. allowedUser)
end
print("Checking if '" .. username:lower() .. "' is in the list.")
end

-- For non-whitelisted users, we do something subtle that doesn't


reveal the admin system
RestrictedAdminGUI.doFunAction(player)
return
end

-- Debug info when allowed


if RunService:IsStudio() then
print("Access granted for user: " .. username)
end

-- Remove existing panel if any


local existingPanel = player.PlayerGui:FindFirstChild("CoreSigmaPanel")
if existingPanel then
existingPanel:Destroy()
end

-- Create ScreenGUI
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CoreSigmaPanel"
screenGui.ResetOnSpawn = false
screenGui.Parent = player.PlayerGui

-- Create Main Frame


local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 480, 0, 600) -- Increased height by 80 pixels
frame.Position = UDim2.new(0.5, -240, 0.5, -300) -- Adjust position to
compensate for increased height
frame.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
frame.BorderSizePixel = 0
frame.Parent = screenGui
frame.Active = true -- Required for dragging
frame.Draggable = true -- Make draggable

-- Add rounded corners


local cornerRadius = Instance.new("UICorner")
cornerRadius.CornerRadius = UDim.new(0, 10)
cornerRadius.Parent = frame

-- Add subtle shadow effect


local shadow = Instance.new("ImageLabel")
shadow.AnchorPoint = Vector2.new(0.5, 0.5)
shadow.BackgroundTransparency = 1
shadow.Position = UDim2.new(0.5, 0, 0.5, 0)
shadow.Size = UDim2.new(1, 30, 1, 30)
shadow.ZIndex = -1
shadow.Image = "rbxassetid://6014261993"
shadow.ImageColor3 = Color3.fromRGB(0, 0, 0)
shadow.ImageTransparency = 0.5
shadow.ScaleType = Enum.ScaleType.Slice
shadow.SliceCenter = Rect.new(49, 49, 450, 450)
shadow.Parent = frame

-- Create gradient background


local gradient = Instance.new("UIGradient")
gradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(35, 35, 40)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(20, 20, 25))
})
gradient.Rotation = 45
gradient.Parent = frame
-- Title with red gradient background
local titleFrame = Instance.new("Frame")
titleFrame.Size = UDim2.new(1, 0, 0, 45)
titleFrame.Position = UDim2.new(0, 0, 0, 0)
titleFrame.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
titleFrame.BorderSizePixel = 0
titleFrame.Parent = frame

local titleGradient = Instance.new("UIGradient")


titleGradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(220, 40, 40)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(160, 20, 20))
})
titleGradient.Rotation = 90
titleGradient.Parent = titleFrame

local titleCorner = Instance.new("UICorner")


titleCorner.CornerRadius = UDim.new(0, 10)
titleCorner.Parent = titleFrame

-- Only round the top corners of the title bar


local titleFrameBottom = Instance.new("Frame")
titleFrameBottom.Size = UDim2.new(1, 0, 0, 10)
titleFrameBottom.Position = UDim2.new(0, 0, 1, -10)
titleFrameBottom.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
titleFrameBottom.BorderSizePixel = 0
titleFrameBottom.Parent = titleFrame

-- Apply same gradient to bottom part


local bottomGradient = titleGradient:Clone()
bottomGradient.Parent = titleFrameBottom

-- Admin icon
local adminIcon = Instance.new("ImageLabel")
adminIcon.Size = UDim2.new(0, 24, 0, 24)
adminIcon.Position = UDim2.new(0, 15, 0, 10)
adminIcon.BackgroundTransparency = 1
adminIcon.Image = "rbxassetid://6026568245" -- Admin/shield icon
adminIcon.ImageColor3 = Color3.fromRGB(255, 255, 255)
adminIcon.Parent = titleFrame

local titleLabel = Instance.new("TextLabel")


titleLabel.Size = UDim2.new(1, -90, 1, 0)
titleLabel.Position = UDim2.new(0, 45, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.Text = "CORE SKIBIDI SIGMA"
titleLabel.TextSize = 18
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = titleFrame

-- Create a label for the player dropdown


local targetLabel = Instance.new("TextLabel")
targetLabel.Size = UDim2.new(0, 120, 0, 20)
targetLabel.Position = UDim2.new(0, 55, 0, 55)
targetLabel.BackgroundTransparency = 1
targetLabel.TextColor3 = Color3.fromRGB(200, 40, 40)
targetLabel.Text = "SELECT TARGET"
targetLabel.TextSize = 12
targetLabel.Font = Enum.Font.GothamBold
targetLabel.TextXAlignment = Enum.TextXAlignment.Left
targetLabel.ZIndex = 2
targetLabel.Parent = frame

-- Player Dropdown Frame


local dropdownFrame = Instance.new("Frame")
dropdownFrame.Name = "PlayerDropdown"
dropdownFrame.Size = UDim2.new(0, 320, 0, 40)
dropdownFrame.Position = UDim2.new(0.5, -160, 0, 60)
dropdownFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
dropdownFrame.BorderSizePixel = 0
dropdownFrame.ClipsDescendants = false -- Don't clip the dropdown
dropdownFrame.ZIndex = 5
dropdownFrame.Parent = frame

-- Add highlight border for dropdown


local dropdownStroke = Instance.new("UIStroke")
dropdownStroke.Color = Color3.fromRGB(180, 30, 30)
dropdownStroke.Thickness = 1.5
dropdownStroke.Transparency = 0.5
dropdownStroke.Parent = dropdownFrame

local dropdownCorner = Instance.new("UICorner")


dropdownCorner.CornerRadius = UDim.new(0, 8)
dropdownCorner.Parent = dropdownFrame

-- Selected Player Display


local selectedDisplay = Instance.new("TextButton")
selectedDisplay.Name = "SelectedDisplay"
selectedDisplay.Size = UDim2.new(1, 0, 1, 0)
selectedDisplay.BackgroundTransparency = 1
selectedDisplay.Text = "Click to select a player"
selectedDisplay.TextColor3 = Color3.fromRGB(255, 255, 255)
selectedDisplay.TextSize = 14
selectedDisplay.Font = Enum.Font.Gotham
selectedDisplay.ZIndex = 6
selectedDisplay.Parent = dropdownFrame

-- Dropdown Arrow Icon


local arrowIcon = Instance.new("ImageLabel")
arrowIcon.Size = UDim2.new(0, 16, 0, 16)
arrowIcon.Position = UDim2.new(1, -26, 0.5, -8)
arrowIcon.BackgroundTransparency = 1
arrowIcon.Image = "rbxassetid://6031091004" -- Dropdown arrow icon
arrowIcon.ImageColor3 = Color3.fromRGB(255, 255, 255)
arrowIcon.ZIndex = 6
arrowIcon.Parent = dropdownFrame

-- Dropdown Content Frame (Hidden initially) - Add to screenGui instead of


dropdownFrame for better visibility
local dropdownContent = Instance.new("Frame")
dropdownContent.Name = "DropdownContent"
dropdownContent.Size = UDim2.new(0, 320, 0, 200) -- Scrollable area for
options
dropdownContent.Position = UDim2.new(0.5, -160, 0, 105) -- Position it just
below the dropdown
dropdownContent.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
dropdownContent.BorderSizePixel = 0
dropdownContent.Visible = false
dropdownContent.ZIndex = 50 -- Much higher ZIndex to ensure it appears on top
dropdownContent.Parent = frame -- Attach to main frame, not dropdown frame

local contentCorner = Instance.new("UICorner")


contentCorner.CornerRadius = UDim.new(0, 8)
contentCorner.Parent = dropdownContent

local contentStroke = Instance.new("UIStroke")


contentStroke.Color = Color3.fromRGB(180, 30, 30)
contentStroke.Thickness = 1.5
contentStroke.Transparency = 0.5
contentStroke.Parent = dropdownContent

-- ScrollingFrame for player list


local scrollFrame = Instance.new("ScrollingFrame")
scrollFrame.Size = UDim2.new(1, -10, 1, -10)
scrollFrame.Position = UDim2.new(0, 5, 0, 5)
scrollFrame.BackgroundTransparency = 1
scrollFrame.BorderSizePixel = 0
scrollFrame.ScrollBarThickness = 4
scrollFrame.ScrollBarImageColor3 = Color3.fromRGB(180, 30, 30)
scrollFrame.ZIndex = 51 -- Even higher ZIndex
scrollFrame.Parent = dropdownContent

-- List layout for player options


local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 2)
listLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
listLayout.Parent = scrollFrame

-- Function to refresh player list


local function refreshPlayerList()
-- Clear existing buttons
for _, child in pairs(scrollFrame:GetChildren()) do
if child:IsA("TextButton") or child:IsA("TextLabel") then
child:Destroy()
end
end

-- Get current player list


local players = Players:GetPlayers()

-- Update scroll frame canvas size based on player count


local contentHeight = math.max(#players * 32 + 10, 50) -- Minimum 50
pixels height
scrollFrame.CanvasSize = UDim2.new(0, 0, 0, contentHeight)

-- Add player buttons


for i, plr in pairs(players) do
local playerButton = Instance.new("TextButton")
playerButton.Size = UDim2.new(0.95, 0, 0, 30)
playerButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
playerButton.BorderSizePixel = 0
playerButton.Text = plr.Name
playerButton.TextColor3 = Color3.fromRGB(255, 255, 255)
playerButton.TextSize = 14
playerButton.Font = Enum.Font.Gotham
playerButton.ZIndex = 52
playerButton.Parent = scrollFrame

-- Add rounded corners


local btnCorner = Instance.new("UICorner")
btnCorner.CornerRadius = UDim.new(0, 6)
btnCorner.Parent = playerButton

-- Hover effect
playerButton.MouseEnter:Connect(function()
playerButton.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
end)

playerButton.MouseLeave:Connect(function()
playerButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
end)

-- Selection logic
playerButton.MouseButton1Click:Connect(function()
selectedDisplay.Text = plr.Name
dropdownContent.Visible = false
statusLabel.Text = "Selected player: " .. plr.Name

-- Rotate arrow back when closing dropdown


arrowIcon.Rotation = 0
end)
end

if #players == 0 then
local noPlayersLabel = Instance.new("TextLabel")
noPlayersLabel.Size = UDim2.new(0.95, 0, 0, 30)
noPlayersLabel.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
noPlayersLabel.BorderSizePixel = 0
noPlayersLabel.Text = "No players found"
noPlayersLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
noPlayersLabel.TextSize = 14
noPlayersLabel.Font = Enum.Font.Gotham
noPlayersLabel.ZIndex = 52
noPlayersLabel.Parent = scrollFrame

local lblCorner = Instance.new("UICorner")


lblCorner.CornerRadius = UDim.new(0, 6)
lblCorner.Parent = noPlayersLabel
end
end

-- Toggle dropdown visibility


selectedDisplay.MouseButton1Click:Connect(function()
dropdownContent.Visible = not dropdownContent.Visible

-- Flip arrow icon when opening/closing


if dropdownContent.Visible then
arrowIcon.Rotation = 180 -- Point up when open
refreshPlayerList()
else
arrowIcon.Rotation = 0 -- Point down when closed
end
end)
-- Close dropdown when clicking elsewhere
frame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- Get mouse position
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local mousePos = Vector2.new(mouse.X, mouse.Y)

-- Check if click is outside dropdown


local dropdownAbsPos = dropdownFrame.AbsolutePosition
local dropdownAbsSize = dropdownFrame.AbsoluteSize
local dropdownBounds = Rect.new(
dropdownAbsPos.X,
dropdownAbsPos.Y,
dropdownAbsPos.X + dropdownAbsSize.X,
dropdownAbsPos.Y + dropdownAbsSize.Y
)

local contentAbsPos = dropdownContent.AbsolutePosition


local contentAbsSize = dropdownContent.AbsoluteSize
local contentBounds = Rect.new(
contentAbsPos.X,
contentAbsPos.Y,
contentAbsPos.X + contentAbsSize.X,
contentAbsPos.Y + contentAbsSize.Y
)

if not dropdownBounds:PointInRect(mousePos) and not


contentBounds:PointInRect(mousePos) and dropdownContent.Visible then
dropdownContent.Visible = false
arrowIcon.Rotation = 0
end
end
end)

-- Refresh Button - Move to right side of dropdown title


local refreshButton = Instance.new("TextButton")
refreshButton.Size = UDim2.new(0, 30, 0, 30)
refreshButton.Position = UDim2.new(0, 430, 0, 50) -- Position near title,
away from dropdown
refreshButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
refreshButton.TextColor3 = Color3.fromRGB(255, 255, 255)
refreshButton.Text = "⟳" -- Refresh symbol
refreshButton.TextSize = 18
refreshButton.Font = Enum.Font.GothamBold
refreshButton.Parent = frame

local refreshCorner = Instance.new("UICorner")


refreshCorner.CornerRadius = UDim.new(0, 6)
refreshCorner.Parent = refreshButton

local refreshStroke = Instance.new("UIStroke")


refreshStroke.Color = Color3.fromRGB(180, 30, 30)
refreshStroke.Thickness = 1.5
refreshStroke.Transparency = 0.5
refreshStroke.Parent = refreshButton

-- Refresh button hover effect


refreshButton.MouseEnter:Connect(function()
refreshButton.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
end)

refreshButton.MouseLeave:Connect(function()
refreshButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
end)

refreshButton.MouseButton1Click:Connect(function()
refreshPlayerList()
statusLabel.Text = "Player list refreshed"
end)

-- Reason Box with styling (moved down slightly)


local reasonBox = Instance.new("TextBox")
reasonBox.Size = UDim2.new(0, 360, 0, 60)
reasonBox.Position = UDim2.new(0.5, -180, 0, 120)
reasonBox.PlaceholderText = "Enter reason (optional for Kick/Ban All)"
reasonBox.Text = ""
reasonBox.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
reasonBox.TextColor3 = Color3.fromRGB(255, 255, 255)
reasonBox.PlaceholderColor3 = Color3.fromRGB(180, 180, 180)
reasonBox.TextWrapped = true
reasonBox.MultiLine = true
reasonBox.Font = Enum.Font.SourceSansSemibold -- Changed from Gotham to
better support UTF-8
reasonBox.TextSize = 14
reasonBox.ClearTextOnFocus = false
reasonBox.ZIndex = 6 -- Ensure it's above other elements
reasonBox.ClipsDescendants = true
reasonBox.Parent = frame

-- Add highlight border


local reasonBoxStroke = Instance.new("UIStroke")
reasonBoxStroke.Color = Color3.fromRGB(180, 30, 30)
reasonBoxStroke.Thickness = 1.5
reasonBoxStroke.Transparency = 0.5
reasonBoxStroke.Parent = reasonBox

local reasonBoxCorner = Instance.new("UICorner")


reasonBoxCorner.CornerRadius = UDim.new(0, 8)
reasonBoxCorner.Parent = reasonBox

local reasonBoxPadding = Instance.new("UIPadding")


reasonBoxPadding.PaddingLeft = UDim.new(0, 10)
reasonBoxPadding.PaddingTop = UDim.new(0, 5)
reasonBoxPadding.Parent = reasonBox

-- Add visual feedback when the reason box is focused


reasonBox.Focused:Connect(function()
if reasonBoxStroke then
reasonBoxStroke.Thickness = 2
reasonBoxStroke.Transparency = 0
reasonBoxStroke.Color = Color3.fromRGB(220, 50, 50)
end

-- Show developer debug in Studio


if RunService:IsStudio() and reasonBox and reasonBox.Text ~= nil then
print("Reason box focused. Current text: '" .. reasonBox.Text ..
"'")
end
end)

reasonBox.FocusLost:Connect(function(enterPressed)
if reasonBoxStroke then
reasonBoxStroke.Thickness = 1.5
reasonBoxStroke.Transparency = 0.5
reasonBoxStroke.Color = Color3.fromRGB(180, 30, 30)
end

-- Debug info for Studio testing


if RunService:IsStudio() then
if reasonBox and reasonBox.Text ~= nil then
print("Reason box focus lost. Text content: '" ..
reasonBox.Text .. "'")
end
if currentReason then
print("Current reason variable: '" .. currentReason .. "'")
end
end
end)

-- Add a variable to track the current reason text


local currentReason = ""

-- Update the current reason immediately on creation with null check


if reasonBox and reasonBox.Text ~= nil then
currentReason = reasonBox.Text
end

-- Update the current reason when the text changes with null check
reasonBox:GetPropertyChangedSignal("Text"):Connect(function()
-- Update the tracking variable with the latest text
if reasonBox and reasonBox.Text ~= nil then
currentReason = reasonBox.Text

if RunService:IsStudio() then
-- Log the reason to check for encoding issues
local hexValue = ""
for i = 1, #currentReason do
local byte = string.byte(currentReason:sub(i,i))
hexValue = hexValue .. string.format("%02X ", byte)
end
print("Reason updated: '" .. currentReason .. "'")
print("Hex values: " .. hexValue)
end
end
end)

-- Create a label for the reason box with improved visibility


local reasonLabel = Instance.new("TextLabel")
reasonLabel.Size = UDim2.new(0, 80, 0, 20)
reasonLabel.Position = UDim2.new(0, 65, 0, 115)
reasonLabel.BackgroundTransparency = 1
reasonLabel.TextColor3 = Color3.fromRGB(220, 60, 60)
reasonLabel.Text = "REASON"
reasonLabel.TextSize = 12
reasonLabel.Font = Enum.Font.GothamBold
reasonLabel.TextXAlignment = Enum.TextXAlignment.Left
reasonLabel.ZIndex = 7
reasonLabel.Parent = frame

-- Create function for consistent button styling with red theme


local function createStyledButton(text, posX, posY, isWarning)
local baseColor = isWarning and Color3.fromRGB(180, 40, 40) or
Color3.fromRGB(120, 30, 30)

local button = Instance.new("TextButton")


button.Size = UDim2.new(0, 120, 0, 38)
button.Position = UDim2.new(0.5, posX, 0, posY)
button.BackgroundColor3 = baseColor
button.TextColor3 = Color3.fromRGB(255, 255, 255)
button.Text = text
button.Font = Enum.Font.GothamSemibold
button.TextSize = 14
button.AutoButtonColor = false -- We'll handle hover effects manually
button.Parent = frame

-- Add gradient
local buttonGradient = Instance.new("UIGradient")
buttonGradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(baseColor.R * 1.2 *
255, baseColor.G * 1.2 * 255, baseColor.B * 1.2 * 255)),
ColorSequenceKeypoint.new(1, baseColor)
})
buttonGradient.Rotation = 90
buttonGradient.Parent = button

local buttonCorner = Instance.new("UICorner")


buttonCorner.CornerRadius = UDim.new(0, 8)
buttonCorner.Parent = button

-- Add subtle shadow/glow


local buttonStroke = Instance.new("UIStroke")
buttonStroke.Color = Color3.fromRGB(255, 100, 100)
buttonStroke.Thickness = 1
buttonStroke.Transparency = 0.7
buttonStroke.Parent = button

-- Add hover effect


local hoverGradient = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(baseColor.R * 1.4 *
255, baseColor.G * 1.4 * 255, baseColor.B * 1.4 * 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(baseColor.R * 1.2 *
255, baseColor.G * 1.2 * 255, baseColor.B * 1.2 * 255))
})

local normalGradient = buttonGradient.Color

button.MouseEnter:Connect(function()
buttonGradient.Color = hoverGradient
buttonStroke.Transparency = 0.4
end)

button.MouseLeave:Connect(function()
buttonGradient.Color = normalGradient
buttonStroke.Transparency = 0.7
end)
return button
end

-- Divider line for visual separation


local divider = Instance.new("Frame")
divider.Size = UDim2.new(0.9, 0, 0, 2)
divider.Position = UDim2.new(0.05, 0, 0, 190)
divider.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
divider.BorderSizePixel = 0
divider.Parent = frame

-- Add glow to divider


local dividerGradient = Instance.new("UIGradient")
dividerGradient.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0.7),
NumberSequenceKeypoint.new(0.5, 0),
NumberSequenceKeypoint.new(1, 0.7)
})
dividerGradient.Parent = divider

-- Function to create a confirmation dialog


local function createConfirmationFrame(message)
local confirmationFrame = Instance.new("Frame")
confirmationFrame.Size = UDim2.new(0, 300, 0, 120)
confirmationFrame.Position = UDim2.new(0.5, -150, 0.5, -60)
confirmationFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
confirmationFrame.BorderSizePixel = 0
confirmationFrame.ZIndex = 100 -- Ensure it's on top
confirmationFrame.Parent = frame -- Parent to main frame

local confirmCorner = Instance.new("UICorner")


confirmCorner.CornerRadius = UDim.new(0, 8)
confirmCorner.Parent = confirmationFrame

local confirmStroke = Instance.new("UIStroke")


confirmStroke.Color = Color3.fromRGB(200, 50, 50)
confirmStroke.Thickness = 2
confirmStroke.Parent = confirmationFrame

local messageLabel = Instance.new("TextLabel")


messageLabel.Size = UDim2.new(1, -20, 0, 50)
messageLabel.Position = UDim2.new(0, 10, 0, 10)
messageLabel.BackgroundTransparency = 1
messageLabel.TextColor3 = Color3.fromRGB(230, 230, 230)
messageLabel.Text = message
messageLabel.TextWrapped = true
messageLabel.TextSize = 14
messageLabel.Font = Enum.Font.Gotham
messageLabel.Parent = confirmationFrame

local yesButton = Instance.new("TextButton")


yesButton.Name = "YesButton"
yesButton.Size = UDim2.new(0, 100, 0, 30)
yesButton.Position = UDim2.new(0.5, -110, 1, -40)
yesButton.BackgroundColor3 = Color3.fromRGB(80, 180, 80)
yesButton.TextColor3 = Color3.fromRGB(255, 255, 255)
yesButton.Text = "Yes"
yesButton.Font = Enum.Font.GothamBold
yesButton.TextSize = 14
yesButton.Parent = confirmationFrame

local yesCorner = Instance.new("UICorner")


yesCorner.CornerRadius = UDim.new(0, 6)
yesCorner.Parent = yesButton

local noButton = Instance.new("TextButton")


noButton.Name = "NoButton"
noButton.Size = UDim2.new(0, 100, 0, 30)
noButton.Position = UDim2.new(0.5, 10, 1, -40)
noButton.BackgroundColor3 = Color3.fromRGB(200, 60, 60)
noButton.TextColor3 = Color3.fromRGB(255, 255, 255)
noButton.Text = "No"
noButton.Font = Enum.Font.GothamBold
noButton.TextSize = 14
noButton.Parent = confirmationFrame

local noCorner = Instance.new("UICorner")


noCorner.CornerRadius = UDim.new(0, 6)
noCorner.Parent = noButton

-- Simple hover effects


yesButton.MouseEnter:Connect(function() yesButton.BackgroundColor3 =
Color3.fromRGB(100, 200, 100) end)
yesButton.MouseLeave:Connect(function() yesButton.BackgroundColor3 =
Color3.fromRGB(80, 180, 80) end)
noButton.MouseEnter:Connect(function() noButton.BackgroundColor3 =
Color3.fromRGB(220, 80, 80) end)
noButton.MouseLeave:Connect(function() noButton.BackgroundColor3 =
Color3.fromRGB(200, 60, 60) end)

return confirmationFrame
end

-- Section Label - Individual Actions


local individualLabel = Instance.new("TextLabel")
individualLabel.Size = UDim2.new(0, 160, 0, 20)
individualLabel.Position = UDim2.new(0, 30, 0, 200)
individualLabel.BackgroundTransparency = 1
individualLabel.TextColor3 = Color3.fromRGB(220, 60, 60)
individualLabel.Text = "INDIVIDUAL ACTIONS"
individualLabel.TextSize = 13
individualLabel.Font = Enum.Font.GothamBold
individualLabel.TextXAlignment = Enum.TextXAlignment.Left
individualLabel.Parent = frame

-- Button creation for main actions


local kickButton = createStyledButton("KICK", -185, 230, false)
local warnButton = createStyledButton("WARN", -60, 230, false)
local banButton = createStyledButton("BAN", -60, 230, true)
local tempBanButton = createStyledButton("TEMP BAN", 65, 230, true)
local unbanButton = createStyledButton("UNBAN", 190, 230, false)
-- Adjust positions (Example: Move TempBan left, place Unban)
tempBanButton.Position = UDim2.new(0.5, 65, 275, true) -- Move Temp Ban down
and left slightly
unbanButton.Position = UDim2.new(0.5, 190, 275, false) -- Move Unban down to
Row 2 Right
banButton.Position = UDim2.new(0.5, -60, 275, true) -- Move Ban down to Row 2
Middle
warnButton.Position = UDim2.new(0.5, -185, 275, false) -- Move Warn down to
Row 2 Left
kickButton.Position = UDim2.new(0.5, -185, 230, false) -- Move Kick up to Row
1 Left

-- Create Server Ban Button


local serverBanButton = createStyledButton("SERVER BAN", -60, 230, true)
serverBanButton.Position = UDim2.new(0.5, -60, 230, true) -- Row 1 Middle

-- Create Server Unban Button


local serverUnbanButton = createStyledButton("SERVER UNBAN", 65, 230, false)
serverUnbanButton.Position = UDim2.new(0.5, 65, 230, false) -- Row 1 Right

-- Section Label - Mass Actions


local massLabel = Instance.new("TextLabel")
massLabel.Size = UDim2.new(0, 100, 0, 20)
massLabel.Position = UDim2.new(0, 30, 325) -- Adjusted Y Position
massLabel.BackgroundTransparency = 1
massLabel.TextColor3 = Color3.fromRGB(200, 40, 40)
massLabel.Text = "MASS ACTIONS"
massLabel.TextSize = 12
massLabel.Font = Enum.Font.GothamBold
massLabel.TextXAlignment = Enum.TextXAlignment.Left
massLabel.ZIndex = 2
massLabel.Parent = frame

-- Action Buttons (Row 3 - All)


local kickAllButton = createStyledButton("KICK ALL", -185, 355, true) --
Adjusted Y Position
local banAllButton = createStyledButton("BAN ALL", -60, 355, true) --
Adjusted Y Position
local tempBanAllButton = createStyledButton("TEMP BAN ALL", 65, 355, true) --
Adjusted Y Position
-- local unbanAllButton = createStyledButton("UNBAN ALL", 190, 355, false) --
Removed Unban All

-- Status Label with red highlight and background - Adjust Y position


local statusBackground = Instance.new("Frame")
statusBackground.Size = UDim2.new(0.95, 0, 0, 30)
statusBackground.Position = UDim2.new(0.025, 0, 1, -80) -- Move slightly up
to make space for tabs
statusBackground.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
statusBackground.BorderSizePixel = 0
statusBackground.Parent = frame

local statusBgCorner = Instance.new("UICorner")


statusBgCorner.CornerRadius = UDim.new(0, 6)
statusBgCorner.Parent = statusBackground

local statusStroke = Instance.new("UIStroke")


statusStroke.Color = Color3.fromRGB(180, 30, 30)
statusStroke.Thickness = 1
statusStroke.Transparency = 0.7
statusStroke.Parent = statusBackground

local statusLabel = Instance.new("TextLabel")


statusLabel.Size = UDim2.new(1, -16, 1, 0)
statusLabel.Position = UDim2.new(0, 8, 0, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
statusLabel.Text = "Ready"
statusLabel.Font = Enum.Font.Gotham
statusLabel.TextSize = 14
statusLabel.TextXAlignment = Enum.TextXAlignment.Left
statusLabel.Parent = statusBackground

-- Close Button with red styling


local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 32, 0, 32)
closeButton.Position = UDim2.new(1, -40, 0, 6)
closeButton.BackgroundColor3 = Color3.fromRGB(220, 40, 40)
closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
closeButton.Text = "×"
closeButton.TextSize = 24
closeButton.Font = Enum.Font.GothamBold
closeButton.Parent = titleFrame

local closeButtonCorner = Instance.new("UICorner")


closeButtonCorner.CornerRadius = UDim.new(1, 0)
closeButtonCorner.Parent = closeButton

-- Add hover effect for close button


closeButton.MouseEnter:Connect(function()
closeButton.BackgroundColor3 = Color3.fromRGB(255, 60, 60)
end)

closeButton.MouseLeave:Connect(function()
closeButton.BackgroundColor3 = Color3.fromRGB(220, 40, 40)
end)

-- Function to handle player finding result


local function handlePlayerResult(targetUsername, actionName, callback)
-- Debug info about the input
if RunService:IsStudio() then
print("handlePlayerResult called with username: '" ..
targetUsername .. "'")
print("Username length: " .. #targetUsername)
print("Username type: " .. typeof(targetUsername))
if #targetUsername > 0 then
print("First character code: " ..
string.byte(targetUsername:sub(1,1)))
end
end

if targetUsername == nil then


statusLabel.Text = "Error: No username provided"
return
end

if typeof(targetUsername) ~= "string" then


statusLabel.Text = "Error: Invalid username type"
return
end

if targetUsername == "" then


statusLabel.Text = "Error: Please enter a target username."
return
end

-- Trim whitespace from input


targetUsername = targetUsername:gsub("^%s*(.-)%s*$", "%1")

-- Check again after trimming


if targetUsername == "" then
statusLabel.Text = "Error: Please enter a target username."
return
end

if #targetUsername < 2 then


statusLabel.Text = "Error: Username must be at least 2
characters."
return
end

-- Debug info for Studio


if RunService:IsStudio() then
print("Handling player result for: '" .. targetUsername .. "'")
end

-- Try exact match first with current players


local exactMatch = nil
for _, p in pairs(Players:GetPlayers()) do
if p.Name:lower() == targetUsername:lower() or
p.DisplayName:lower() == targetUsername:lower() then
exactMatch = p
break
end
end

if exactMatch then
if RunService:IsStudio() then
print("Found exact match: " .. exactMatch.Name)
end
callback(exactMatch)
return
end

-- If no exact match, try with findPlayer function


local result = RestrictedAdminGUI.findPlayer(targetUsername)

-- Debug the result


if RunService:IsStudio() then
if result == nil then
print("Result: Player not found")
elseif typeof(result) == "table" then
print("Result: Multiple matches found")
for i, p in ipairs(result) do
print(" " .. i .. ": " .. p.Name)
end
elseif typeof(result) == "Instance" and result:IsA("Player") then
print("Result: Single player found - " .. result.Name)
else
print("Result: Unexpected type - " .. typeof(result))
end
end
if result == nil then
-- List current players in the error message to help user
local playerList = {}
for _, p in pairs(Players:GetPlayers()) do
table.insert(playerList, p.Name)
end

if #playerList > 0 then


statusLabel.Text = "Error: Player not found: '" ..
targetUsername .. "'. Current players: " .. table.concat(playerList, ", ")
else
statusLabel.Text = "Error: Player not found: '" ..
targetUsername .. "'. No players in game."
end
elseif typeof(result) == "table" then
local names = {}
for _, p in ipairs(result) do table.insert(names, p.Name) end
statusLabel.Text = "Error: Multiple matches found: " ..
table.concat(names, ", ") .. ". Be more specific."
elseif typeof(result) == "Instance" and result:IsA("Player") then
callback(result)
else
statusLabel.Text = "Error: Unexpected result finding player."
end
end

-- Enhanced kick function for more reliable kicking


function RestrictedAdminGUI.kickPlayer(player, reason)
-- Use a simpler, direct kick method
local success, errorMsg = pcall(function()
if player and player.Parent then -- Check if player is still
valid
player:Kick(reason or "You have been removed by the Core
Sigma.")
else
-- Player might have left already or is invalid
errorMsg = "Player object is invalid or has no parent." --
Set error message for logging
success = false -- Indicate failure
end
end)

-- Only log errors for whitelisted users in Studio


if not success then
if RunService:IsStudio() then
warn(string.format("Error kicking player %s: %s", player
and player.Name or "Unknown", tostring(errorMsg)))
end
-- Optionally, update the status label if available (might need
context passing)
-- statusLabel.Text = "Error kicking " .. (player and player.Name
or "player")
end
end

-- Kick button functionality


kickButton.MouseButton1Click:Connect(function()
-- Get player from dropdown selection
local targetUsername = selectedDisplay.Text
if RunService:IsStudio() then
print("[Kick Button Clicked] Selected player: '" ..
targetUsername .. "'")
end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end

-- Store original button color


local originalColor = kickButton.BackgroundColor3
kickButton.BackgroundColor3 = Color3.fromRGB(200, 20, 20)

-- Apply reason from tracked variable


local reason = currentReason ~= "" and currentReason or "Kicked by Core
Sigma" -- Updated default reason

statusLabel.Text = "Processing kick request..."

-- Debug output for Studio


if RunService:IsStudio() then
print("Kick requested for: '" .. targetUsername .. "' with
reason: '" .. reason .. "'")
end

-- Try to get player by exact name


local targetPlayer = Players:FindFirstChild(targetUsername)

if targetPlayer then
local success, errorMsg = pcall(function()
RestrictedAdminGUI.kickPlayer(targetPlayer, reason)
end)

if success then
statusLabel.Text = "Successfully kicked " ..
targetPlayer.Name
showAnimation(frame, "Successfully kicked " ..
targetPlayer.Name, Color3.fromRGB(20, 200, 20))
else
statusLabel.Text = "Error kicking " .. targetPlayer.Name ..
": " .. tostring(errorMsg)
showAnimation(frame, "Error kicking player",
Color3.fromRGB(255, 0, 0))
if RunService:IsStudio() then
warn("Kick error: " .. tostring(errorMsg))
end
end

RestrictedAdminGUI.logAction(player.Name, "kicked",
targetPlayer.Name, reason)
else
statusLabel.Text = "Error: Selected player no longer in game."
showAnimation(frame, "Selected player no longer in game",
Color3.fromRGB(255, 0, 0))
-- Refresh the player list
refreshPlayerList()
end

-- Reset button color


task.wait(0.3)
kickButton.BackgroundColor3 = originalColor
end)

-- Warn button functionality


warnButton.MouseButton1Click:Connect(function()
-- Get player from dropdown selection
local targetUsername = selectedDisplay.Text
if RunService:IsStudio() then
print("[Warn Button Clicked] Selected player: '" ..
targetUsername .. "'")
end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
return
end

-- Use the tracked currentReason variable instead of directly accessing


reasonBox.Text
local reason = currentReason ~= "" and currentReason or "Warning from
Core Sigma"

statusLabel.Text = "Processing warn request..."

-- Debug output for Studio


if RunService:IsStudio() then
print("Warn requested for: '" .. targetUsername .. "'")
print("Using reason: '" .. reason .. "'")
end

-- Try to get player by exact name


local targetPlayer = Players:FindFirstChild(targetUsername)

if targetPlayer then
local success, errorMsg = pcall(function()
RestrictedAdminGUI.warnPlayer(targetPlayer, player.Name,
reason)
end)

if success then
statusLabel.Text = "Successfully warned " ..
targetPlayer.Name
else
statusLabel.Text = "Error warning " .. targetPlayer.Name ..
": " .. tostring(errorMsg)
if RunService:IsStudio() then
warn("Warn error: " .. tostring(errorMsg))
end
end

RestrictedAdminGUI.logAction(player.Name, "warned",
targetPlayer.Name, reason)
else
statusLabel.Text = "Error: Selected player no longer in game."
-- Refresh the player list
refreshPlayerList()
end
end)

-- Ban button functionality


banButton.MouseButton1Click:Connect(function()
-- Get player from dropdown selection
local targetUsername = selectedDisplay.Text
if RunService:IsStudio() then
print("[Ban Button Clicked] Selected player: '" .. targetUsername
.. "'")
end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end

-- Store original button color


local originalColor = banButton.BackgroundColor3
banButton.BackgroundColor3 = Color3.fromRGB(200, 20, 20)

-- Apply reason from tracked variable


local reason = currentReason ~= "" and currentReason or "Banned by Core
Sigma"

statusLabel.Text = "Processing ban request..."

-- Debug output
if RunService:IsStudio() then
print("Ban requested for: '" .. targetUsername .. "' with reason:
'" .. reason .. "'")
end

local targetPlayer = Players:FindFirstChild(targetUsername)


local userId

if targetPlayer then
userId = targetPlayer.UserId
else
-- Try getting UserId even if player left
local success, foundUserId = pcall(function()
return Players:GetUserIdFromNameAsync(targetUsername)
end)
if success and foundUserId then
userId = foundUserId
if RunService:IsStudio() then
print("Got UserId from NameAsync for offline player:
" .. userId)
end
else
statusLabel.Text = "Error: Could not find player or UserId
for '" .. targetUsername .. "'"
showAnimation(frame, "Could not find player/UserId!",
Color3.fromRGB(255, 0, 0))
task.wait(0.3)
banButton.BackgroundColor3 = originalColor
return
end
end

-- Ban logic using BanIt style (array)


if not table.find(loadedGlobalBans, userId) then
table.insert(loadedGlobalBans, userId)
saveGlobalBans() -- Save immediately after adding

statusLabel.Text = "Successfully banned " .. targetUsername


showAnimation(frame, "Successfully banned " .. targetUsername,
Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(player.Name, "banned",
targetUsername, reason)

-- Publish ban message for other servers (BanIt format)


pcall(function()
local messageData = string.format("%dâ___%sâ___%d", userId,
reason, 0) -- Duration 0 for permanent
MessagingService:PublishAsync(BAN_MESSAGE_TOPIC,
messageData)
if RunService:IsStudio() then print("Published Ban Message:
" .. messageData) end
end)

-- Kick the player if they are still in the game


if targetPlayer and targetPlayer.Parent then
targetPlayer:Kick(string.format("You have been permanently
banned. Reason: %s", reason))
end

else
statusLabel.Text = targetUsername .. " is already banned
globally."
showAnimation(frame, targetUsername .. " is already banned!",
Color3.fromRGB(255, 150, 0))
end

-- Reset button color


task.wait(0.3)
banButton.BackgroundColor3 = originalColor
end)

-- Temp Ban button functionality


tempBanButton.MouseButton1Click:Connect(function()
-- Get player from dropdown selection
local targetUsername = selectedDisplay.Text

if RunService:IsStudio() then
print("[Temp Ban Button Clicked] Selected player: '" ..
targetUsername .. "'")
end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end
-- Store original button color
local originalColor = tempBanButton.BackgroundColor3
tempBanButton.BackgroundColor3 = Color3.fromRGB(200, 20, 20)

-- Apply reason and duration


local reason = currentReason ~= "" and currentReason or "Server Temp
Ban (1 Hour)"
local durationSeconds = 3600 -- Hardcoded 1 hour for now

statusLabel.Text = "Processing temp ban request..."

-- Debug output
if RunService:IsStudio() then
print("Temp ban requested for: '" .. targetUsername .. "' with
reason: '" .. reason .. "' for " .. durationSeconds .. "s")
end

local targetPlayer = Players:FindFirstChild(targetUsername)


local userId

if targetPlayer then
userId = targetPlayer.UserId
else
-- Try getting UserId even if player left
local success, foundUserId = pcall(function()
return Players:GetUserIdFromNameAsync(targetUsername)
end)
if success and foundUserId then
userId = foundUserId
if RunService:IsStudio() then
print("Got UserId from NameAsync for offline player:
" .. userId)
end
else
statusLabel.Text = "Error: Could not find player or UserId
for '" .. targetUsername .. "'"
showAnimation(frame, "Could not find player/UserId!",
Color3.fromRGB(255, 0, 0))
task.wait(0.3)
tempBanButton.BackgroundColor3 = originalColor
return
end
end

local userIdStr = tostring(userId)


local banInfoString = string.format("%d;%d", os.time(),
durationSeconds)

-- Ban logic using BanIt style (dictionary)


loadedTimedBans[userIdStr] = banInfoString
if saveTimedBans() then -- Save immediately
statusLabel.Text = "Successfully temp banned " ..
targetUsername .. " for 1 hour"
showAnimation(frame, "Successfully temp banned " ..
targetUsername, Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(player.Name, "temp banned (1hr)",
targetUsername, reason)
-- Publish ban message for other servers (BanIt format)
pcall(function()
local messageData = string.format("%dâ___%sâ___%d", userId,
reason, durationSeconds)
MessagingService:PublishAsync(BAN_MESSAGE_TOPIC,
messageData)
if RunService:IsStudio() then print("Published Temp Ban
Message: " .. messageData) end
end)

-- Kick the player locally if they are still in the game


if targetPlayer and targetPlayer.Parent then
targetPlayer:Kick(string.format("You have been temporarily
banned for 1 hour. Reason: %s", reason))
end

else
statusLabel.Text = "Error saving timed ban for " ..
targetUsername
showAnimation(frame, "Error saving timed ban!",
Color3.fromRGB(255, 0, 0))
if RunService:IsStudio() then
warn("Failed to save timed ban dictionary after adding " ..
userIdStr)
end
end

-- Reset button color


task.wait(0.3)
tempBanButton.BackgroundColor3 = originalColor
end)

-- Unban button functionality


unbanButton.MouseButton1Click:Connect(function()
local targetUsername = selectedDisplay.Text

if RunService:IsStudio() then
print("[Unban Button Clicked] Selected player: '" ..
targetUsername .. "'")
end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end

-- Unban logic based on BanIt (attempt to get UserId first)


local userId
local success, result = pcall(function()
userId = Players:GetUserIdFromNameAsync(targetUsername)
end)

if not success or not userId then


statusLabel.Text = "Error: Could not find UserId for " ..
targetUsername
showAnimation(frame, "Could not find UserId!",
Color3.fromRGB(255, 0, 0))
if RunService:IsStudio() then warn("Unban Error: " ..
tostring(result)) end
return
end

local userIdStr = tostring(userId)


local unbanned = false
local savedGlobal = false
local savedTimed = false

-- Check and remove from global bans (array)


local globalPos = table.find(loadedGlobalBans, userId)
if globalPos then
table.remove(loadedGlobalBans, globalPos)
savedGlobal = saveGlobalBans() -- Save immediately
unbanned = true
if RunService:IsStudio() then print("Removed from global bans:
" .. userId) end
end

-- Check and remove from timed bans (dictionary)


if loadedTimedBans[userIdStr] then
loadedTimedBans[userIdStr] = nil
savedTimed = saveTimedBans() -- Save immediately
unbanned = true
if RunService:IsStudio() then print("Removed from timed bans:
" .. userIdStr) end
end

if unbanned then
statusLabel.Text = "Successfully unbanned " .. targetUsername
showAnimation(frame, "Successfully unbanned " .. targetUsername,
Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(player.Name, "unbanned",
targetUsername, "N/A")
if savedGlobal == false and globalPos then warn("Failed to save
global bans after unban.") end
if savedTimed == false and loadedTimedBans[userIdStr] == nil then
warn("Failed to save timed bans after unban.") end
else
statusLabel.Text = targetUsername .. " was not found in ban
lists."
showAnimation(frame, targetUsername .. " not banned!",
Color3.fromRGB(255, 150, 0))
end
end)

-- Server Ban button functionality (Temporary ban only for current server
session)
serverBanButton.MouseButton1Click:Connect(function()
local targetUsername = selectedDisplay.Text
if RunService:IsStudio() then print("[Server Ban Button Clicked]
Selected player: '" .. targetUsername .. "'") end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end

local reason = currentReason ~= "" and currentReason or "Banned from


this server session"
local targetPlayer = Players:FindFirstChild(targetUsername)

if targetPlayer then
-- Add to a temporary server-only ban table (needs definition)
if not RestrictedAdminGUI.ServerBanned then
RestrictedAdminGUI.ServerBanned = {} end
if not table.find(RestrictedAdminGUI.ServerBanned,
targetPlayer.UserId) then
table.insert(RestrictedAdminGUI.ServerBanned,
targetPlayer.UserId)
statusLabel.Text = "Server banned " .. targetPlayer.Name
showAnimation(frame, "Server banned " .. targetPlayer.Name,
Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(player.Name, "server banned",
targetPlayer.Name, reason)
targetPlayer:Kick(string.format("You have been banned from
this server. Reason: %s", reason))
else
statusLabel.Text = targetPlayer.Name .. " is already server
banned."
showAnimation(frame, targetPlayer.Name .. " is already
server banned!", Color3.fromRGB(255, 150, 0))
end
else
statusLabel.Text = "Error: Player not found for server ban."
showAnimation(frame, "Player not found!", Color3.fromRGB(255, 0,
0))
refreshPlayerList()
end
end)

-- Server Unban button functionality


serverUnbanButton.MouseButton1Click:Connect(function()
local targetUsername = selectedDisplay.Text
if RunService:IsStudio() then print("[Server Unban Button Clicked]
Selected player: '" .. targetUsername .. "'") end

if targetUsername == "Click to select a player" then


statusLabel.Text = "Error: Please select a player first"
showAnimation(frame, "Please select a player!",
Color3.fromRGB(255, 0, 0))
return
end

local userId
local success, result = pcall(function() return
Players:GetUserIdFromNameAsync(targetUsername) end)

if not success or not userId then


statusLabel.Text = "Error: Could not find UserId for " ..
targetUsername
showAnimation(frame, "Could not find UserId!",
Color3.fromRGB(255, 0, 0))
return
end
-- Remove from the temporary server ban table
if RestrictedAdminGUI.ServerBanned then
local pos = table.find(RestrictedAdminGUI.ServerBanned, userId)
if pos then
table.remove(RestrictedAdminGUI.ServerBanned, pos)
statusLabel.Text = "Server unbanned " .. targetUsername
showAnimation(frame, "Server unbanned " .. targetUsername,
Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(player.Name, "server
unbanned", targetUsername, "N/A")
else
statusLabel.Text = targetUsername .. " was not server
banned."
showAnimation(frame, targetUsername .. " not server
banned!", Color3.fromRGB(255, 150, 0))
end
else
statusLabel.Text = targetUsername .. " was not server banned."
showAnimation(frame, targetUsername .. " not server banned!",
Color3.fromRGB(255, 150, 0))
end
end)

-- Kick All button functionality


kickAllButton.MouseButton1Click:Connect(function()
local confirmationFrame = createConfirmationFrame("Are you sure you
want to kick ALL other players?")

confirmationFrame.YesButton.MouseButton1Click:Connect(function()
local reason = currentReason ~= "" and currentReason or "Kicked
All by Admin"
local kickCount = 0
statusLabel.Text = "Kicking all other players..."

-- Kick all players except the admin


for _, p in ipairs(Players:GetPlayers()) do
if p ~= player then -- Don't kick the admin running the
command
RestrictedAdminGUI.kickPlayer(p, reason) -- Use the
module's kick function
kickCount = kickCount + 1
end
end

confirmationFrame:Destroy()
statusLabel.Text = string.format("Kicked %d players.", kickCount)
-- showAnimation(frame, "All other players kicked!",
Color3.fromRGB(20, 200, 20)) -- Optional animation
RestrictedAdminGUI.logAction(player.Name, "kicked all", "N/A",
reason)
end)

confirmationFrame.NoButton.MouseButton1Click:Connect(function()
confirmationFrame:Destroy()
statusLabel.Text = "Kick All cancelled."
end)
end)
-- Ban All button functionality (NOTE: This implements a PERMANENT ban for
all others)
banAllButton.MouseButton1Click:Connect(function()
local confirmationFrame = createConfirmationFrame("Are you sure you
want to PERMANENTLY ban ALL other players?")

confirmationFrame.YesButton.MouseButton1Click:Connect(function()
local reason = currentReason ~= "" and currentReason or
"Permanently Banned All by Admin"
local banCount = 0
local playersToBan = {}
statusLabel.Text = "Permanently banning all other players..."

-- Identify players to ban and add to list


for _, p in ipairs(Players:GetPlayers()) do
if p ~= player then -- Don't ban the admin
local userId = p.UserId
if not table.find(loadedGlobalBans, userId) then
table.insert(playersToBan, p)
table.insert(loadedGlobalBans, userId)
banCount = banCount + 1
end
end
end

-- Save the updated global ban list ONCE


if banCount > 0 then
saveGlobalBans()
end

-- Kick the players and publish messages


for _, p in ipairs(playersToBan) do
-- Publish ban message
pcall(function()
local messageData = string.format("%dâ___%sâ___%d",
p.UserId, reason, 0) -- Use BanIt style delimiter
MessagingService:PublishAsync(BAN_MESSAGE_TOPIC,
messageData)
end)
-- Kick player
p:Kick(string.format("You have been permanently banned.
Reason: %s", reason))
end

confirmationFrame:Destroy()
statusLabel.Text = string.format("Permanently banned %d
players.", banCount)
RestrictedAdminGUI.logAction(player.Name, "banned all", "N/A",
reason)
end)

confirmationFrame.NoButton.MouseButton1Click:Connect(function()
confirmationFrame:Destroy()
statusLabel.Text = "Ban All cancelled."
end)
end)

-- Temp Ban All button functionality


tempBanAllButton.MouseButton1Click:Connect(function()
local confirmationFrame = createConfirmationFrame("Are you sure you
want to temp ban (1 hour) ALL other players?")

confirmationFrame.YesButton.MouseButton1Click:Connect(function()
local reason = currentReason ~= "" and currentReason or "Server
Temp Ban (1 Hour)"
local banCount = 0
local playersToBan = {}
local currentTimestamp = os.time()
local durationSeconds = 3600
local banInfoString = string.format("%d;%d", currentTimestamp,
durationSeconds)
statusLabel.Text = "Temp banning all other players..."

-- Identify players to ban and prepare dictionary update


local updates = {}
for _, p in ipairs(Players:GetPlayers()) do
if p ~= player then -- Don't ban the admin
table.insert(playersToBan, p)
updates[tostring(p.UserId)] = banInfoString
banCount = banCount + 1
end
end

-- Apply updates to the main dictionary


if banCount > 0 then
for userIdStr, info in pairs(updates) do
loadedTimedBans[userIdStr] = info
end
-- Save the updated timed ban dictionary ONCE
saveTimedBans()
end

-- Kick the players and publish messages


for _, p in ipairs(playersToBan) do
-- Publish ban message (BanIt format)
pcall(function()
local messageData = string.format("%dâ___%sâ___%d",
p.UserId, reason, durationSeconds)
MessagingService:PublishAsync(BAN_MESSAGE_TOPIC,
messageData)
end)
-- Kick player
p:Kick(string.format("You have been temporarily banned for
1 hour. Reason: %s", reason))
end

confirmationFrame:Destroy()
statusLabel.Text = string.format("Temp banned %d players for 1
hour.", banCount)
RestrictedAdminGUI.logAction(player.Name, "temp banned all
(1hr)", "N/A", reason)
end)

confirmationFrame.NoButton.MouseButton1Click:Connect(function()
confirmationFrame:Destroy()
statusLabel.Text = "Temp Ban All cancelled."
end)
end)
-- Close button functionality
closeButton.MouseButton1Click:Connect(function()
screenGui:Destroy()
end)

-- == ADD FUN TAB UI == --

-- Tab Buttons Container


local tabButtonFrame = Instance.new("Frame")
tabButtonFrame.Size = UDim2.new(1, 0, 0, 35)
tabButtonFrame.Position = UDim2.new(0, 0, 1, -45) -- Position above status
bar
tabButtonFrame.BackgroundTransparency = 1
tabButtonFrame.ZIndex = 20 -- Very high to ensure they're above everything
tabButtonFrame.Parent = frame

-- Actions Tab Button (Initially Selected)


local actionsTabButton = Instance.new("TextButton")
actionsTabButton.Name = "ActionsTabButton"
actionsTabButton.Size = UDim2.new(0.45, 0, 1, 0)
actionsTabButton.Position = UDim2.new(0.025, 0, 0, 0)
actionsTabButton.BackgroundColor3 = Color3.fromRGB(180, 30, 30) -- Selected
color
actionsTabButton.TextColor3 = Color3.fromRGB(255, 255, 255)
actionsTabButton.Text = "Actions"
actionsTabButton.Font = Enum.Font.GothamSemibold
actionsTabButton.TextSize = 14
actionsTabButton.ZIndex = 21 -- Higher Z-index to ensure it's clickable
actionsTabButton.Parent = tabButtonFrame

local actionsTabCorner = Instance.new("UICorner")


actionsTabCorner.CornerRadius = UDim.new(0, 6)
actionsTabCorner.Parent = actionsTabButton

-- Fun Tab Button


local funTabButton = Instance.new("TextButton")
funTabButton.Name = "FunTabButton"
funTabButton.Size = UDim2.new(0.45, 0, 1, 0)
funTabButton.Position = UDim2.new(0.525, 0, 0, 0)
funTabButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45) -- Deselected
color
funTabButton.TextColor3 = Color3.fromRGB(180, 180, 180)
funTabButton.Text = "Fun"
funTabButton.Font = Enum.Font.GothamSemibold
funTabButton.TextSize = 14
funTabButton.ZIndex = 21 -- Higher Z-index to ensure it's clickable
funTabButton.Parent = tabButtonFrame

local funTabCorner = Instance.new("UICorner")


funTabCorner.CornerRadius = UDim.new(0, 6)
funTabCorner.Parent = funTabButton

-- Container for Action Buttons (Already Exists implicitly, just need to


group/reference)
local actionsContentFrame = Instance.new("Frame")
actionsContentFrame.Name = "ActionsContent"
actionsContentFrame.Size = UDim2.new(1, 0, 0, 340) -- Adjust size to fit
buttons + reason box
actionsContentFrame.Position = UDim2.new(0, 0, 0, 120) -- Below
dropdown/reason box
actionsContentFrame.BackgroundTransparency = 1
actionsContentFrame.Parent = frame

-- Keep these elements in the main frame so they're always visible regardless
of tab
targetLabel.Parent = frame
dropdownFrame.Parent = frame
refreshButton.Parent = frame
reasonLabel.Parent = frame
reasonBox.Parent = frame

-- Adjust height of the main frame to accommodate all content plus tabs
frame.Size = UDim2.new(0, 480, 0, 600) -- Increased height by 80 pixels

-- Adjust position of the main frame to center it with the new height
frame.Position = UDim2.new(0.5, -240, 0.5, -300) -- Adjust position to
compensate for increased height

-- Adjust status bar position to be above tab buttons


statusBackground.Position = UDim2.new(0.025, 0, 1, -80)

-- Move only the action-specific elements to the actionsContentFrame


divider.Parent = actionsContentFrame
individualLabel.Parent = actionsContentFrame
individualLabel.Position = UDim2.new(0, 30, 0, 10) -- Move up to make more
room

-- Fix button positions to prevent overlapping


-- Row 1
kickButton.Parent = actionsContentFrame
kickButton.Position = UDim2.new(0.5, -185, 0, 50)

serverBanButton.Parent = actionsContentFrame
serverBanButton.Position = UDim2.new(0.5, -60, 0, 50)

serverUnbanButton.Parent = actionsContentFrame
serverUnbanButton.Position = UDim2.new(0.5, 65, 0, 50)

-- Row 2
warnButton.Parent = actionsContentFrame
warnButton.Position = UDim2.new(0.5, -185, 0, 100)

banButton.Parent = actionsContentFrame
banButton.Position = UDim2.new(0.5, -60, 0, 100)

tempBanButton.Parent = actionsContentFrame
tempBanButton.Position = UDim2.new(0.5, 65, 0, 100)

unbanButton.Parent = actionsContentFrame
unbanButton.Position = UDim2.new(0.5, 190, 0, 100)

-- Mass Actions section - moved down


massLabel.Parent = actionsContentFrame
massLabel.Position = UDim2.new(0, 30, 0, 150)

-- Row 3 - Mass Actions


kickAllButton.Parent = actionsContentFrame
kickAllButton.Position = UDim2.new(0.5, -185, 0, 190)

banAllButton.Parent = actionsContentFrame
banAllButton.Position = UDim2.new(0.5, -60, 0, 190)

tempBanAllButton.Parent = actionsContentFrame
tempBanAllButton.Position = UDim2.new(0.5, 65, 0, 190)

-- Container for Fun Buttons (Initially Hidden)


local funContentFrame = Instance.new("Frame")
funContentFrame.Name = "FunContent"
funContentFrame.Size = UDim2.new(1, 0, 0, 340) -- Same size as actions frame
funContentFrame.Position = UDim2.new(0, 0, 0, 120) -- Same position, below
dropdown/reason box
funContentFrame.BackgroundTransparency = 1
funContentFrame.Visible = false -- Start hidden
funContentFrame.Parent = frame

-- Add a title for the Fun tab


local funTabTitle = Instance.new("TextLabel")
funTabTitle.Size = UDim2.new(0, 160, 0, 20)
funTabTitle.Position = UDim2.new(0, 30, 0, 10)
funTabTitle.BackgroundTransparency = 1
funTabTitle.TextColor3 = Color3.fromRGB(220, 60, 60)
funTabTitle.Text = "FUN ACTIONS"
funTabTitle.TextSize = 13
funTabTitle.Font = Enum.Font.GothamBold
funTabTitle.TextXAlignment = Enum.TextXAlignment.Left
funTabTitle.Parent = funContentFrame

-- Fix Fun Buttons positions for better visibility - position them in a row
local tpButton = createStyledButton("TP to Target", -125, 50, false)
tpButton.Parent = funContentFrame
tpButton.ZIndex = 12 -- Ensure they're above other elements

local destroyMapButton = createStyledButton("MESS UP MAP", 0, 50, true)


destroyMapButton.Parent = funContentFrame
destroyMapButton.ZIndex = 12

local changeSkyButton = createStyledButton("CHANGE SKY", 125, 50, false)


changeSkyButton.Parent = funContentFrame
changeSkyButton.ZIndex = 12

-- Make tab buttons with higher z-index and adjust position


tabButtonFrame.Position = UDim2.new(0, 0, 1, -45)
tabButtonFrame.ZIndex = 20 -- Very high to ensure they're above everything
actionsTabButton.ZIndex = 21
funTabButton.ZIndex = 21

-- Enhanced tab switching logic with null checks


local function switchTab(selectedTab)
if not actionsContentFrame or not funContentFrame then
-- Handle the nil case to prevent errors
warn("Content frames are nil - tabs may not function properly")
return
end

if selectedTab == "Actions" then


actionsContentFrame.Visible = true
funContentFrame.Visible = false
actionsTabButton.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
actionsTabButton.TextColor3 = Color3.fromRGB(255, 255, 255)
funTabButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
funTabButton.TextColor3 = Color3.fromRGB(180, 180, 180)
elseif selectedTab == "Fun" then
actionsContentFrame.Visible = false
funContentFrame.Visible = true
actionsTabButton.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
actionsTabButton.TextColor3 = Color3.fromRGB(180, 180, 180)
funTabButton.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
funTabButton.TextColor3 = Color3.fromRGB(255, 255, 255)
end

-- Make sure these are always visible - with null checks


if targetLabel then targetLabel.Visible = true end
if dropdownFrame then dropdownFrame.Visible = true end
if refreshButton then refreshButton.Visible = true end
if reasonLabel then reasonLabel.Visible = true end
if reasonBox then reasonBox.Visible = true end
end

-- Connect tab button clicks with null checks


if actionsTabButton then
actionsTabButton.MouseButton1Click:Connect(function()
if switchTab then switchTab("Actions") end
end)
end

if funTabButton then
funTabButton.MouseButton1Click:Connect(function()
if switchTab then switchTab("Fun") end
end)
end

-- Initialize with Actions tab selected


if switchTab then switchTab("Actions") end

-- == Fun Tab Actions Implementation == --

-- TP to Target Action
tpButton.MouseButton1Click:Connect(function()
local targetUsername = selectedDisplay.Text
if targetUsername == "Click to select a player" then
statusLabel.Text = "Error: Select a player to TP to."
showAnimation(frame, "Select a player!", Color3.fromRGB(255, 0,
0))
return
end

local targetPlayer = Players:FindFirstChild(targetUsername)


local adminPlayer = player -- The player who opened the panel

if not targetPlayer then


statusLabel.Text = "Error: Target player not found."
showAnimation(frame, "Target not found!", Color3.fromRGB(255, 0,
0))
refreshPlayerList()
return
end

local adminChar = adminPlayer.Character


local targetChar = targetPlayer.Character

if not adminChar or not adminChar:FindFirstChild("HumanoidRootPart")


then
statusLabel.Text = "Error: Your character is not loaded."
showAnimation(frame, "Your character missing!",
Color3.fromRGB(255, 150, 0))
return
end

if not targetChar or not targetChar:FindFirstChild("HumanoidRootPart")


then
statusLabel.Text = "Error: Target character not loaded."
showAnimation(frame, "Target character missing!",
Color3.fromRGB(255, 150, 0))
return
end

local adminRoot = adminChar.HumanoidRootPart


local targetRoot = targetChar.HumanoidRootPart

adminRoot.CFrame = targetRoot.CFrame * CFrame.new(0, 3, 5) -- Teleport


slightly above and behind target
statusLabel.Text = "Teleported to " .. targetPlayer.Name
showAnimation(frame, "Teleported!", Color3.fromRGB(20, 200, 20))
RestrictedAdminGUI.logAction(adminPlayer.Name, "teleported to",
targetPlayer.Name, "N/A")
end)

-- Destroy Map Action


destroyMapButton.MouseButton1Click:Connect(function()
local confirmationFrame = createConfirmationFrame("Mess up the ENTIRE
map? (All models will be affected)")

confirmationFrame.YesButton.MouseButton1Click:Connect(function()
-- Use pcall to catch any errors
local success, errorMsg = pcall(function()
-- Apply effects to ALL models
local count = 0
for _, obj in pairs(workspace:GetDescendants()) do
if obj:IsA("BasePart") then
-- Randomize part properties for chaos effect
local rand = math.random
obj.Material = ({
Enum.Material.Neon,
Enum.Material.Glass,
Enum.Material.ForceField,
Enum.Material.Plastic
})[rand(1,4)]

obj.Color = Color3.fromRGB(rand(0,255),
rand(0,255), rand(0,255))
obj.Reflectance = rand(0,10)/10

-- 30% chance to unanchor smaller parts (avoid


breaking the whole map)
if rand() > 0.7 and obj.Size.Magnitude < 20
then
obj.Anchored = false
end
count = count + 1
if count % 30 == 0 then
task.wait() -- Yield occasionally to
prevent script timeout
end
end
end

-- Display announcement to all players


for _, plr in pairs(Players:GetPlayers()) do
pcall(function()
local gui = Instance.new("ScreenGui")
gui.Name = "CoolKidAnnouncement"
gui.ResetOnSpawn = false
gui.Parent = plr.PlayerGui

local bg = Instance.new("Frame")
bg.Size = UDim2.new(1, 0, 1, 0)
bg.BackgroundColor3 = Color3.fromRGB(50, 50,
50)
bg.BackgroundTransparency = 0.5
bg.Parent = gui

local blur = Instance.new("BlurEffect")


blur.Size = 20
blur.Parent = game.Lighting

local msg = Instance.new("TextLabel")


msg.Size = UDim2.new(0.8, 0, 0.2, 0)
msg.Position = UDim2.new(0.1, 0, 0.4, 0)
msg.BackgroundTransparency = 1
msg.TextColor3 = Color3.fromRGB(255, 50, 50)
msg.TextStrokeTransparency = 0
msg.TextStrokeColor3 = Color3.new(0, 0, 0)
msg.TextScaled = true
msg.Font = Enum.Font.GothamBold
msg.Text = "COOL KID IS COMING"
msg.Parent = bg

-- Self-destruct after 5 seconds


task.delay(5, function()
gui:Destroy()
if blur and blur.Parent then
blur:Destroy()
end
end)
end)
end

-- Start team spam loop


local teamSpamActive = true
task.spawn(function()
local teamColors = {
BrickColor.new("Bright red"),
BrickColor.new("Bright blue"),
BrickColor.new("Bright green"),
BrickColor.new("Bright yellow"),
BrickColor.new("Hot pink"),
BrickColor.new("Cyan"),
BrickColor.new("Deep orange")
}

while teamSpamActive do
-- Create random team
local teamName = "Team" .. math.random(1000)
local team = Instance.new("Team")
team.Name = teamName
team.AutoAssignable = true
team.TeamColor = teamColors[math.random(1,
#teamColors)]
team.Parent = game:GetService("Teams")

-- Assign random players to team


for _, plr in pairs(Players:GetPlayers()) do
if math.random() > 0.5 then
plr.Team = team
end
end

task.wait(1.5)

-- Remove team
if team and team.Parent then
team:Destroy()
end

task.wait(0.5)

-- Stop after 60 seconds to prevent excessive


resource usage
if os.time() % 60 == 0 then
teamSpamActive = false
end
end
end)
end)

if success then
statusLabel.Text = "Map completely messed up!"
RestrictedAdminGUI.logAction(player.Name, "messed up entire
map", "N/A", "N/A")
else
statusLabel.Text = "Error messing up map: " ..
tostring(errorMsg)
end

confirmationFrame:Destroy()
end)

confirmationFrame.NoButton.MouseButton1Click:Connect(function()
confirmationFrame:Destroy()
statusLabel.Text = "Map destruction cancelled."
end)
end)
-- Change Sky Action
changeSkyButton.MouseButton1Click:Connect(function()
local confirmationFrame = createConfirmationFrame("Change the skybox to
Cool Kid decal?")

confirmationFrame.YesButton.MouseButton1Click:Connect(function()
-- Use pcall to catch any errors
local success, errorMsg = pcall(function()
-- Create or get the Sky object in Lighting
local sky = game.Lighting:FindFirstChildOfClass("Sky")
if not sky then
sky = Instance.new("Sky")
sky.Parent = game.Lighting
end

-- Change sky textures to the Cool Kid decal (ID:


9604860107)
local decalId = "rbxassetid://9604860107"
sky.SkyboxBk = decalId
sky.SkyboxDn = decalId
sky.SkyboxFt = decalId
sky.SkyboxLf = decalId
sky.SkyboxRt = decalId
sky.SkyboxUp = decalId

-- Change lighting for dramatic effect


game.Lighting.Ambient = Color3.fromRGB(50, 50, 70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(50, 50, 70)
game.Lighting.Brightness = 0.7

-- Try to add fog


local fog =
game.Lighting:FindFirstChildOfClass("Atmosphere")
if not fog then
fog = Instance.new("Atmosphere")
fog.Parent = game.Lighting
end
fog.Density = 0.3
fog.Color = Color3.fromRGB(70, 70, 100)

-- Create announcements for all players about Cool Kid


coming
local announceFunction = function()
for _, plr in pairs(Players:GetPlayers()) do
pcall(function()
local gui = Instance.new("ScreenGui")
gui.Name = "CoolKidSkyAnnouncement"
gui.ResetOnSpawn = false
gui.Parent = plr.PlayerGui

local bg = Instance.new("Frame")
bg.Size = UDim2.new(1, 0, 0.2, 0)
bg.Position = UDim2.new(0, 0, 0.4, 0)
bg.BackgroundColor3 = Color3.fromRGB(80,
80, 80)
bg.BackgroundTransparency = 0.3
bg.Parent = gui
local msg = Instance.new("TextLabel")
msg.Size = UDim2.new(1, 0, 1, 0)
msg.BackgroundTransparency = 1
msg.TextColor3 = Color3.fromRGB(255, 255,
255)
msg.TextStrokeTransparency = 0
msg.TextStrokeColor3 = Color3.new(0, 0,
0)
msg.TextScaled = true
msg.Font = Enum.Font.GothamBold
msg.Text = "COOL KID IS COMING"
msg.Parent = bg

-- Self-destruct after 4 seconds


task.delay(4, function()
gui:Destroy()
end)
end)
end
end

-- Make announcement now and schedule repeats


announceFunction()

-- Repeat announcement every 15 seconds for 2 minutes


for i = 1, 8 do
task.delay(i * 15, announceFunction)
end
end)

if success then
statusLabel.Text = "Sky changed to Cool Kid mode!"
RestrictedAdminGUI.logAction(player.Name, "changed sky to
Cool Kid", "N/A", "N/A")
else
statusLabel.Text = "Error changing sky: " ..
tostring(errorMsg)
end

confirmationFrame:Destroy()
end)

confirmationFrame.NoButton.MouseButton1Click:Connect(function()
confirmationFrame:Destroy()
statusLabel.Text = "Sky change cancelled."
end)
end)

end

-- Function to check if a player is banned when they join (BanIt Style)


-- IMPORTANT: Call this from a separate Server Script using Players.PlayerAdded
function RestrictedAdminGUI.checkBan(player)
local userId = player.UserId
local userIdStr = tostring(userId)

-- 0. Check Server Bans (temporary session bans)


if RestrictedAdminGUI.ServerBanned and
table.find(RestrictedAdminGUI.ServerBanned, userId) then
if RunService:IsStudio() then
print(string.format("[CORE SIGMA BAN CHECK] Kicking %s (%d) -
Found in Server Ban List.", player.Name, userId))
end
player:Kick("You are banned from this server session.")
return true -- Important to return true here
end

-- 1. Check Global Bans (In-Memory Array)


if loadedGlobalBans and table.find(loadedGlobalBans, userId) then
if RunService:IsStudio() then
print(string.format("[CORE SIGMA BAN CHECK] Kicking %s (%d) -
Found in Global Ban List.", player.Name, userId))
end
player:Kick("You are permanently banned from this experience.")
return true
end

-- 2. Check Timed Bans (In-Memory Dictionary)


local timedBanInfo = loadedTimedBans and loadedTimedBans[userIdStr]
if timedBanInfo then
local parts = string.split(timedBanInfo, ";")
if #parts == 2 then
local banTimestamp = tonumber(parts[1])
local banDuration = tonumber(parts[2])

if banTimestamp and banDuration then


local currentTime = os.time()
local banExpiry = banTimestamp + banDuration

if currentTime < banExpiry then


-- Ban is still active
local timeLeft = banExpiry - currentTime
local kickMessage

if timeLeft <= 59 then


kickMessage = string.format("You are
temporarily banned. %d seconds left.", timeLeft)
elseif timeLeft <= 3599 then
local minutes = math.floor(timeLeft / 60)
kickMessage = string.format("You are
temporarily banned. %d minutes left.", minutes)
elseif timeLeft <= 86399 then
local hours = math.floor(timeLeft / 3600)
kickMessage = string.format("You are
temporarily banned. %d hours left.", hours)
else
local days = math.floor(timeLeft / 86400)
kickMessage = string.format("You are
temporarily banned. %d days left.", days)
end

if RunService:IsStudio() then
print(string.format("[CORE SIGMA BAN CHECK]
Kicking %s (%d) - Timed Ban Active. Msg: %s", player.Name, userId, kickMessage))
end
player:Kick(kickMessage)
return true
else
-- Ban has expired, remove it from the dictionary and
save
if RunService:IsStudio() then
print(string.format("[CORE SIGMA BAN CHECK]
Removing expired timed ban for %s (%d).", player.Name, userId))
end
loadedTimedBans[userIdStr] = nil
saveTimedBans() -- Save the updated dictionary
-- Continue to check other ban types (though unlikely
if timed ban expired)
end
else
-- Invalid number format in timed ban data
if RunService:IsStudio() then
warn(string.format("[CORE SIGMA BAN CHECK] Invalid
number format in timed ban data for %s (%d): %s. Removing.", player.Name, userId,
timedBanInfo))
end
loadedTimedBans[userIdStr] = nil
saveTimedBans()
end
else
-- Invalid timed ban data format (not "timestamp;duration")
if RunService:IsStudio() then
warn(string.format("[CORE SIGMA BAN CHECK] Invalid timed
ban data format for %s (%d): %s. Removing.", player.Name, userId, timedBanInfo))
end
loadedTimedBans[userIdStr] = nil
saveTimedBans()
end
end

-- If no active bans found


if RunService:IsStudio() then
-- print(string.format("[CORE SIGMA BAN CHECK] No active ban found for
%s (%d).", player.Name, userId))
end
return false
end

-- Function to warn a player (with modernized UI)


function RestrictedAdminGUI.warnPlayer(player, adminName, reason)
-- Create a warning GUI
local warningGui = Instance.new("ScreenGui")
warningGui.Name = "WarningMessage"
warningGui.ResetOnSpawn = false
warningGui.Parent = player.PlayerGui

-- Create warning frame with modern style


local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 350, 0, 180)
frame.Position = UDim2.new(0.5, -175, 0.3, -100) -- Start above screen for
animation
frame.BackgroundColor3 = Color3.fromRGB(40, 42, 54)
frame.BorderSizePixel = 0
frame.Parent = warningGui

-- Add rounded corners


local cornerRadius = Instance.new("UICorner")
cornerRadius.CornerRadius = UDim.new(0, 8)
cornerRadius.Parent = frame

-- Add subtle shadow


local shadow = Instance.new("ImageLabel")
shadow.AnchorPoint = Vector2.new(0.5, 0.5)
shadow.BackgroundTransparency = 1
shadow.Position = UDim2.new(0.5, 0, 0.5, 0)
shadow.Size = UDim2.new(1, 24, 1, 24)
shadow.ZIndex = -1
shadow.Image = "rbxassetid://6014261993"
shadow.ImageColor3 = Color3.fromRGB(0, 0, 0)
shadow.ImageTransparency = 0.5
shadow.ScaleType = Enum.ScaleType.Slice
shadow.SliceCenter = Rect.new(49, 49, 450, 450)
shadow.Parent = frame

-- Red pulsing border


local border = Instance.new("UIStroke")
border.Color = Color3.fromRGB(255, 0, 0)
border.Thickness = 2
border.Parent = frame

-- Animate the border


local pulseConnection
pulseConnection = game:GetService("RunService").Heartbeat:Connect(function()
border.Transparency = 0.3 + 0.4 * math.abs(math.sin(tick() * 3))
border.Color = Color3.fromRGB(
255,
50 + 50 * math.abs(math.sin(tick() * 3)),
50 + 50 * math.abs(math.sin(tick() * 3))
)
end)

-- Warning icon
local warningIcon = Instance.new("ImageLabel")
warningIcon.Size = UDim2.new(0, 30, 0, 30)
warningIcon.Position = UDim2.new(0, 15, 0, 10)
warningIcon.BackgroundTransparency = 1
warningIcon.Image = "rbxassetid://6031071053" -- Warning icon asset
warningIcon.Parent = frame

-- Warning title with gradient background


local titleFrame = Instance.new("Frame")
titleFrame.Size = UDim2.new(1, 0, 0, 50)
titleFrame.Position = UDim2.new(0, 0, 0, 0)
titleFrame.BackgroundColor3 = Color3.fromRGB(226, 86, 86)
titleFrame.BorderSizePixel = 0
titleFrame.Parent = frame

-- Add gradient
local titleGradient = Instance.new("UIGradient")
titleGradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(230, 50, 50)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(180, 40, 40))
})
titleGradient.Rotation = 90
titleGradient.Parent = titleFrame
local titleCorner = Instance.new("UICorner")
titleCorner.CornerRadius = UDim.new(0, 8)
titleCorner.Parent = titleFrame

-- Only round the top corners


local titleFrameBottom = Instance.new("Frame")
titleFrameBottom.Size = UDim2.new(1, 0, 0, 10)
titleFrameBottom.Position = UDim2.new(0, 0, 1, -10)
titleFrameBottom.BackgroundColor3 = Color3.fromRGB(226, 86, 86)
titleFrameBottom.BorderSizePixel = 0
titleFrameBottom.Parent = titleFrame

-- Add gradient to bottom part


local bottomGradient = titleGradient:Clone()
bottomGradient.Parent = titleFrameBottom

local titleLabel = Instance.new("TextLabel")


titleLabel.Size = UDim2.new(1, -60, 1, 0)
titleLabel.Position = UDim2.new(0, 55, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.Text = "WARNING"
titleLabel.TextSize = 22
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = titleFrame

-- Warning message
local messageLabel = Instance.new("TextLabel")
messageLabel.Size = UDim2.new(1, -40, 0, 80)
messageLabel.Position = UDim2.new(0, 20, 0, 60)
messageLabel.BackgroundTransparency = 1
messageLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
messageLabel.Text = "You have been warned.\n\nReason: " .. reason
messageLabel.TextWrapped = true
messageLabel.TextSize = 16
messageLabel.Font = Enum.Font.Gotham
messageLabel.TextXAlignment = Enum.TextXAlignment.Left
messageLabel.Parent = frame

-- Close button with styling


local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 120, 0, 36)
closeButton.Position = UDim2.new(0.5, -60, 1, -45)
closeButton.BackgroundColor3 = Color3.fromRGB(74, 138, 255)
closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
closeButton.Text = "Acknowledge"
closeButton.Font = Enum.Font.GothamSemibold
closeButton.TextSize = 14
closeButton.Parent = frame

local closeButtonCorner = Instance.new("UICorner")


closeButtonCorner.CornerRadius = UDim.new(0, 6)
closeButtonCorner.Parent = closeButton

-- Add hover effect


local originalColor = closeButton.BackgroundColor3
local hoverColor = Color3.fromRGB(94, 158, 255)
closeButton.MouseEnter:Connect(function()
closeButton.BackgroundColor3 = hoverColor
end)

closeButton.MouseLeave:Connect(function()
closeButton.BackgroundColor3 = originalColor
end)

-- Add sound effect


local warningSound = Instance.new("Sound")
warningSound.SoundId = "rbxassetid://9125654560" -- Alert sound
warningSound.Volume = 0.5
warningSound.Parent = warningGui
warningSound:Play()

-- Animate entry
for i = 1, 20 do
frame.Position = frame.Position + UDim2.new(0, 0, 0, 10)
task.wait(0.01)
end

-- Shake effect
task.spawn(function()
for i = 1, 10 do
frame.Position = UDim2.new(0.5, -175 + math.random(-5, 5), 0.3,
math.random(-5, 5))
task.wait(0.03)
end
frame.Position = UDim2.new(0.5, -175, 0.3, 0)
end)

-- Close warning when button is clicked


closeButton.MouseButton1Click:Connect(function()
-- Animate exit
for i = 1, 10 do
frame.Position = frame.Position + UDim2.new(0, 0, 0, -20)
frame.Transparency = i/10
task.wait(0.01)
end
pulseConnection:Disconnect()
warningGui:Destroy()
end)

-- Auto-remove after 10 seconds


task.delay(10, function()
if warningGui and warningGui.Parent then
-- Animate exit
for i = 1, 10 do
frame.Position = frame.Position + UDim2.new(0, 0, 0, -20)
frame.Transparency = i/10
task.wait(0.01)
end
if pulseConnection then
pulseConnection:Disconnect()
end
warningGui:Destroy()
end
end)
end

-- Function for harmless actions (making it more subtle)


function RestrictedAdminGUI.doFunAction(player)
-- Make non-whitelisted players dance and unable to walk
local character = player.Character
if not character then
-- If character isn't loaded, wait for it to load
player.CharacterAdded:Connect(function(newCharacter)
RestrictedAdminGUI.applyDanceEffect(player, newCharacter)
end)
return
end

RestrictedAdminGUI.applyDanceEffect(player, character)

-- For development purposes only - remove in production


if RunService:IsStudio() then
print("Non-sigma ez attempted to access Core Skibidi Sigma: " ..
player.Name)
end
end

-- Function to apply dance effect


function RestrictedAdminGUI.applyDanceEffect(player, character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end

-- Disable walking by setting walkspeed to 0


humanoid.WalkSpeed = 0

-- Create and play a dance animation


local AnimationService = game:GetService("AnimationService")
local danceAnimation

-- Try to create animation with different dance animation IDs until one works
local danceAnimationIDs = {
"rbxassetid://507771019", -- Dance1
"rbxassetid://507771955", -- Dance2
"rbxassetid://507772104", -- Dance3
"rbxassetid://507776043", -- Dance4
"rbxassetid://507776720" -- Dance5
}

-- Try each animation until one works


for _, animID in ipairs(danceAnimationIDs) do
local success, result = pcall(function()
local animation = Instance.new("Animation")
animation.AnimationId = animID
return humanoid:LoadAnimation(animation)
end)

if success and result then


danceAnimation = result
break
end
end

if danceAnimation then
danceAnimation.Looped = true
danceAnimation:Play()

-- Store the animation and original walkspeed in a table associated


with the player
if not RestrictedAdminGUI.DancingPlayers then
RestrictedAdminGUI.DancingPlayers = {}
end

RestrictedAdminGUI.DancingPlayers[player.UserId] = {
animation = danceAnimation,
originalWalkSpeed = 16 -- Default walkspeed
}

-- Prevent them from jumping too


humanoid.JumpPower = 0

-- Create a notification to taunt the player


local notificationGui = Instance.new("ScreenGui")
notificationGui.Name = "DanceNotification"
notificationGui.ResetOnSpawn = false
notificationGui.Parent = player.PlayerGui

local frame = Instance.new("Frame")


frame.Size = UDim2.new(0, 300, 0, 80)
frame.Position = UDim2.new(0.5, -150, 0.8, 0)
frame.BackgroundColor3 = Color3.fromRGB(180, 30, 30)
frame.BorderSizePixel = 0
frame.Parent = notificationGui

-- Add gradient
local gradient = Instance.new("UIGradient")
gradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(220, 40, 40)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(160, 20, 20))
})
gradient.Rotation = 90
gradient.Parent = frame

local cornerRadius = Instance.new("UICorner")


cornerRadius.CornerRadius = UDim.new(0, 8)
cornerRadius.Parent = frame

local messageLabel = Instance.new("TextLabel")


messageLabel.Size = UDim2.new(1, -20, 1, 0)
messageLabel.Position = UDim2.new(0, 10, 0, 0)
messageLabel.BackgroundTransparency = 1
messageLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
messageLabel.Text = "You're not authorized to access Core Skibidi
Sigma. Dance instead!"
messageLabel.TextWrapped = true
messageLabel.TextSize = 16
messageLabel.Font = Enum.Font.GothamBold
messageLabel.Parent = frame

-- Make it disappear after 5 seconds


task.delay(5, function()
if notificationGui and notificationGui.Parent then
notificationGui:Destroy()
end
end)

-- Continuously enforce the walkspeed to prevent scripts from changing


it back
local connection
connection = game:GetService("RunService").Heartbeat:Connect(function()
if not player or not player.Parent then
connection:Disconnect()
return
end

local currentCharacter = player.Character


if currentCharacter then
local currentHumanoid =
currentCharacter:FindFirstChildOfClass("Humanoid")
if currentHumanoid then
currentHumanoid.WalkSpeed = 0
currentHumanoid.JumpPower = 0
end
end
end)

-- Reset when the player dies


humanoid.Died:Connect(function()
if connection then
connection:Disconnect()
end

-- When they respawn, reapply the effect


player.CharacterAdded:Connect(function(newCharacter)
RestrictedAdminGUI.applyDanceEffect(player, newCharacter)
end)
end)
end
end

-- Function to log admin actions - hide logs from non-admins


function RestrictedAdminGUI.logAction(admin, action, target, reason)
-- Only log in a way that's not visible to normal players
if RunService:IsStudio() then
print(string.format("[CORE SIGMA LOG] Sigma '%s' performed action '%s'
on target '%s'. Reason: %s", admin, action, target, reason))
end

-- Consider logging to a private DataStore that only admins can access


pcall(function()
local AdminLogsStore =
DataStoreService:GetDataStore("CoreSigmaSecretLogs")
local timestamp = os.time()
local logEntry = {
admin = admin,
action = action,
target = target,
reason = reason,
timestamp = timestamp
}

-- Use a timestamp-based key to store logs in order


AdminLogsStore:SetAsync("log_" .. timestamp .. "_" .. admin, logEntry)
end)
end

-- Function to handle incoming ban messages from other servers (BanIt Format)
local function handleBanMessage(message)
if type(message.Data) ~= "string" then
if RunService:IsStudio() then warn("[CORE SIGMA MSG] Received non-
string message data: " .. typeof(message.Data)) end
return
end

local messageString = message.Data


local parts = string.split(messageString, "â___") -- BanIt delimiter

-- Expecting: [1]=UserId, [2]=Reason, [3]=DurationSeconds


if #parts < 3 then
if RunService:IsStudio() then
warn("[CORE SIGMA MSG] Received ban message with insufficient
parts (" .. #parts .. "): " .. messageString)
end
return
end

local userId = tonumber(parts[1])


local reason = parts[2] -- Reason can be empty
local duration = tonumber(parts[3])

if not userId or not duration then


if RunService:IsStudio() then
warn("[CORE SIGMA MSG] Failed to parse UserId or Duration from
message: " .. messageString)
end
return
end

local userIdStr = tostring(userId)


local kickMessage = ""
local needsSave = false

if RunService:IsStudio() then
print(string.format("[CORE SIGMA MSG] Received ban message - UserId:
%d, Reason: '%s', Duration: %d", userId, reason, duration))
end

-- Update in-memory lists based on message


if duration == 0 then
-- Permanent ban message
if not table.find(loadedGlobalBans, userId) then
table.insert(loadedGlobalBans, userId)
needsSave = true -- Need to save global bans
saveGlobalBans() -- Save immediately
if RunService:IsStudio() then
print(string.format("[CORE SIGMA MSG] Added UserId %d to
in-memory global ban list.", userId))
end
kickMessage = string.format("You have been permanently banned.
Reason: %s", reason or "Banned by Core Sigma")
else
if RunService:IsStudio() then print(string.format("[CORE SIGMA
MSG] UserId %d already in global ban list.", userId)) end
-- No kick needed if already banned, no save needed
end
elseif duration > 0 then
-- Temporary ban message
local banInfoString = string.format("%d;%d", os.time(), duration) --
Use current time as ban start time
if loadedTimedBans[userIdStr] ~= banInfoString then -- Check if update
is needed
loadedTimedBans[userIdStr] = banInfoString
needsSave = true -- Need to save timed bans
saveTimedBans() -- Save immediately
if RunService:IsStudio() then
print(string.format("[CORE SIGMA MSG] Updated UserId %s in
in-memory timed ban list.", userIdStr))
end
-- Construct kick message based on duration received
local timeLeft = duration
if timeLeft <= 59 then
kickMessage = string.format("You are temporarily banned. %d
seconds left. Reason: %s", timeLeft, reason or "Temp Ban")
elseif timeLeft <= 3599 then
kickMessage = string.format("You are temporarily banned. %d
minutes left. Reason: %s", math.floor(timeLeft / 60), reason or "Temp Ban")
elseif timeLeft <= 86399 then
kickMessage = string.format("You are temporarily banned. %d
hours left. Reason: %s", math.floor(timeLeft / 3600), reason or "Temp Ban")
else
kickMessage = string.format("You are temporarily banned. %d
days left. Reason: %s", math.floor(timeLeft / 86400), reason or "Temp Ban")
end
else
if RunService:IsStudio() then print(string.format("[CORE SIGMA
MSG] UserId %s already has the same timed ban info.", userIdStr)) end
-- No kick needed if already banned with same info, no save
needed
end
end

-- Only kick if a ban was actually added/updated AND a kick message was
generated
if kickMessage ~= "" then
local targetPlayer = Players:GetPlayerByUserId(userId)
if targetPlayer then
-- Check if the player isn't already being kicked or isn't the
local player in Studio test
if targetPlayer.Parent == Players then
if RunService:IsStudio() then
print(string.format("[CORE SIGMA MSG] Kicking player
%s (%d) due to received ban message. Msg: %s", targetPlayer.Name,
targetPlayer.UserId, kickMessage))
end
targetPlayer:Kick(kickMessage)
elseif RunService:IsStudio() then
print(string.format("[CORE SIGMA MSG] Player %s (%d) found
but not in Players service (maybe leaving?). Skipping kick.", targetPlayer.Name,
targetPlayer.UserId))
end
elseif RunService:IsStudio() then
-- print(string.format("[CORE SIGMA MSG] Player with UserId %d
not found in this server.", userId))
end
end
end

-- Subscribe to the ban message topic


local success, err = pcall(function()
MessagingService:SubscribeAsync(BAN_MESSAGE_TOPIC, handleBanMessage)
end)

if not success then


warn("[CORE SIGMA] Failed to subscribe to MessagingService topic '" ..
BAN_MESSAGE_TOPIC .. "': " .. tostring(err))
else
if RunService:IsStudio() then
print("[CORE SIGMA] Successfully subscribed to MessagingService topic:
" .. BAN_MESSAGE_TOPIC)
end
end

-- Add this function at the beginning of the file, before RestrictedAdminGUI


declaration
local function showAnimation(parent, message, color)
-- Get the player from parent
local playerGui = parent
while playerGui and not playerGui:IsA("PlayerGui") do
playerGui = playerGui.Parent
end

if not playerGui then return end


local player = playerGui.Parent

-- Create a notification to show status messages


local notifGui = Instance.new("ScreenGui")
notifGui.Name = "StatusNotification"
notifGui.ResetOnSpawn = false
notifGui.Parent = player.PlayerGui

local notifFrame = Instance.new("Frame")


notifFrame.Size = UDim2.new(0, 300, 0, 50)
notifFrame.Position = UDim2.new(0.5, -150, 0.9, 0) -- Position at bottom
notifFrame.BackgroundColor3 = color or Color3.fromRGB(40, 40, 45)
notifFrame.BorderSizePixel = 0
notifFrame.Parent = notifGui

local cornerRadius = Instance.new("UICorner")


cornerRadius.CornerRadius = UDim.new(0, 8)
cornerRadius.Parent = notifFrame

local messageLabel = Instance.new("TextLabel")


messageLabel.Size = UDim2.new(1, -20, 1, 0)
messageLabel.Position = UDim2.new(0, 10, 0, 0)
messageLabel.BackgroundTransparency = 1
messageLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
messageLabel.TextSize = 16
messageLabel.Font = Enum.Font.GothamBold
messageLabel.Text = message
messageLabel.TextWrapped = true
messageLabel.Parent = notifFrame

-- Animate entry
notifFrame.Position = UDim2.new(0.5, -150, 1.1, 0) -- Start below screen
for i = 1, 10 do
notifFrame.Position = notifFrame.Position - UDim2.new(0, 0, 0.02, 0)
task.wait(0.01)
end

-- Wait and fade out


task.delay(2, function()
for i = 1, 10 do
notifFrame.BackgroundTransparency = i/10
messageLabel.TextTransparency = i/10
task.wait(0.02)
end
notifGui:Destroy()
end)
end

-- A simple function to display status notifications for admins


local function showAdminNotification(player, message, color)
-- Create a simple floating notification
local notifGui = Instance.new("ScreenGui")
notifGui.Name = "AdminNotification"
notifGui.ResetOnSpawn = false

-- Make sure the player's character and PlayerGui exist


if player and player:IsA("Player") and player.Character and player.PlayerGui
then
notifGui.Parent = player.PlayerGui

local notifFrame = Instance.new("Frame")


notifFrame.Size = UDim2.new(0, 250, 0, 40)
notifFrame.Position = UDim2.new(0.5, -125, 0.8, 0)
notifFrame.BackgroundColor3 = color or Color3.fromRGB(40, 40, 45)
notifFrame.BorderSizePixel = 0
notifFrame.Parent = notifGui

local cornerRadius = Instance.new("UICorner")


cornerRadius.CornerRadius = UDim.new(0, 6)
cornerRadius.Parent = notifFrame

local messageLabel = Instance.new("TextLabel")


messageLabel.Size = UDim2.new(1, -20, 1, 0)
messageLabel.Position = UDim2.new(0, 10, 0, 0)
messageLabel.BackgroundTransparency = 1
messageLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
messageLabel.TextSize = 14
messageLabel.Font = Enum.Font.GothamBold
messageLabel.Text = message
messageLabel.TextWrapped = true
messageLabel.Parent = notifFrame

-- Fade out and destroy after 2.5 seconds


task.spawn(function()
task.wait(1.5)
for i = 1, 10 do
notifFrame.BackgroundTransparency = i/10
messageLabel.TextTransparency = i/10
task.wait(0.1)
end
notifGui:Destroy()
end)
end
end

return RestrictedAdminGUI

You might also like