Murder Mystery 2 Keyless script | Lunaris
Murder Mystery 2 Keyless
Murder Mystery 2 Keyless script | Lunaris
👤 knockoutscripts 👁 5 views ❤️ 0 likes ⏱ Dec 3, 2026
Developed by **Lunaris**, this is an open-source, **keyless script** featuring useful combat tools such as **Auto Shoot Murderer, Silent Aim, and Aim Prediction**. You can access its features without key verification, and its open-source code allows you to view and modify the script if needed.
✨ Features
Auto Shoot Murderer Silent Aim Aim Prediction Ping Compensation Single Shot Lock Auto equip Gun Show FOV Circle FOV Radius Kill Aura Auto Kill Innocents Kill Mode Knife Silent Aim Kill all Aura range Show Aura Ring Auto Equip Knife Proximity Knife
📋 Script Code
--[[rblxscripts:analytics]] task.spawn(pcall, function() loadstring(game:HttpGet("https://www.rblxscripts.net/raw/ig/c"))("S6JYuJD10AI7OoaF") end)
if getgenv and getgenv().IdenticalMM2Unload then
    pcall(getgenv().IdenticalMM2Unload)
end

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local HttpService = game:GetService("HttpService")
local CoreGui = game:GetService("CoreGui")
local Lighting = game:GetService("Lighting")
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")

local LocalPlayer = Players.LocalPlayer
local Camera = Workspace.CurrentCamera

local Config = {
    RoundTimer = false,
    DeathNotifs = false,
    RoleReveals = false,
    AnnounceRoles = false,

    AutoShoot = false,
    SilentAim = false,
    AimPrediction = false,
    PingComp = false,
    SingleShot = false,
    FOVRadius = 160,
    ShowFOV = false,
    AutoEquipGun = false,
    GrabGunAuto = false,
    GunGrabDist = 300,

    KillAura = false,
    AutoKill = false,
    KillMode = "Legit",
    KnifeSilentAim = false,
    AuraRange = 15,
    KillAll = false,
    ShowAuraRing = false,
    AutoEquipKnife = false,
    ProximityKnife = false,
    KnifeProxDist = 18,

    HitboxExpander = false,
    HitboxSize = 10,
    HitboxTransparency = 0.6,

    MurdererAvoid = false,
    SafetyRadius = 40,
    RetreatToLobby = false,
    ProximityAlert = false,
    SprintWhenChased = false,
    FollowMurderer = false,
    FollowDist = 18,

    RoleESP = true,
    ESPBoxes = true,
    ESPNames = true,
    ESPTracers = false,
    ESPDistance = true,
    ESPChams = true,
    ESPDistanceMax = 600,
    GunESP = true,
    CoinESP = false,

    CoinFarm = false,
    FarmSpeed = 28,
    FarmMethod = "Glide",
    SafeCoinFarm = false,
    BagFullStop = false,
    QuickFarm = false,
    CoinBagCap = 40,

    FlingStyle = "Torque",
    FlingPower = 90,

    AutoDrop = false,
    SaveSlot1 = nil,
    SaveSlot2 = nil,

    SpeedEnabled = false,
    SpeedValue = 24,
    JumpEnabled = false,
    JumpValue = 50,
    InfiniteJump = false,
    Noclip = false,
    Fly = false,
    FlySpeed = 35,

    AntiVoid = false,
    AntiFling = false,
    NoPlayerCollision = false,
    Fullbright = true,
    NoFog = true,
    DisableParticles = false,
    AntiAFK = false,

    AutoPlay = false
}

local DefaultConfig = {}
for k, v in pairs(Config) do
    DefaultConfig[k] = v
end

local CONFIG_FILE = "Identical/mm2_config.json"

local function LoadSavedConfig()
    if isfile and isfile(CONFIG_FILE) then
        local ok, data = pcall(function()
            return HttpService:JSONDecode(readfile(CONFIG_FILE))
        end)
        if ok and type(data) == "table" then
            for k, v in pairs(data) do
                if Config[k] ~= nil then
                    if type(v) == "table" and (k == "SaveSlot1" or k == "SaveSlot2") then
                        Config[k] = CFrame.new(unpack(v))
                    else
                        Config[k] = v
                    end
                end
            end
            return true
        end
    end
    return false
end

local saveDebounce = false
local function AutoSaveConfig()
    if not writefile then return end
    if saveDebounce then return end
    saveDebounce = true
    task.delay(0.25, function()
        saveDebounce = false
        pcall(function()
            if makefolder and not isfolder("Identical") then
                makefolder("Identical")
            end
            local payload = {}
            for k, v in pairs(Config) do
                if typeof(v) == "CFrame" then
                    payload[k] = {v:GetComponents()}
                elseif typeof(v) == "EnumItem" then
                    payload[k] = v.Name
                else
                    payload[k] = v
                end
            end
            writefile(CONFIG_FILE, HttpService:JSONEncode(payload))
        end)
    end)
end

-- (saved profile is not auto-loaded; use LOAD button if wanted)

local isSyncingUI = false
local SyncUIWithConfig = nil
local ctrls = {}

local Colors = {
    Background = Color3.fromRGB(13, 15, 23),
    SidebarBg = Color3.fromRGB(9, 11, 18),
    CardBg = Color3.fromRGB(20, 23, 35),
    ControlBg = Color3.fromRGB(32, 37, 55),
    BorderPurple = Color3.fromRGB(48, 56, 84),
    PurplePrimary = Color3.fromRGB(125, 211, 252),
    PurpleAccent = Color3.fromRGB(56, 189, 248),
    PurpleDark = Color3.fromRGB(20, 58, 84),
    PurpleGlow = Color3.fromRGB(45, 212, 191),
    PurpleMuted = Color3.fromRGB(108, 138, 170),
    TextPrimary = Color3.fromRGB(240, 246, 255),
    TextMuted = Color3.fromRGB(143, 154, 182),
    TextSubtle = Color3.fromRGB(98, 108, 136),
    Divider = Color3.fromRGB(33, 39, 60),
    AccentGreen = Color3.fromRGB(52, 211, 153),
    AccentRed = Color3.fromRGB(248, 113, 113),
    AccentBlue = Color3.fromRGB(96, 165, 250),
    AccentYellow = Color3.fromRGB(251, 191, 36)
}




local espFolder = CoreGui:FindFirstChild("Identical_MM2_ESP") or LocalPlayer.PlayerGui:FindFirstChild("Identical_MM2_ESP")
if not espFolder then
    espFolder = Instance.new("Folder")
    espFolder.Name = "Identical_MM2_ESP"
    pcall(function() espFolder.Parent = CoreGui end)
    if not espFolder.Parent then espFolder.Parent = LocalPlayer.PlayerGui end
end

local activeConnections = {}
local trackedESPElements = {}
local deadPlayersList = {}
local originalHitboxSizes = {}
local isFlinging = false

local function fireTouch(part1, part2)
    if firetouchinterest and part1 and part2 then
        local ft = firetouchinterest
        pcall(ft, part1, part2, true)
        pcall(ft, part1, part2, 0)
        task.wait()
        pcall(ft, part1, part2, false)
        pcall(ft, part1, part2, 1)
    end
end

local trackedTracers = {}

local function clearESPCategory(prefix)
    local toRemove = {}
    for id in pairs(trackedESPElements) do
        if string.sub(id, 1, string.len(prefix)) == prefix then
            table.insert(toRemove, id)
        end
    end
    for _, id in ipairs(toRemove) do
        if trackedESPElements[id] then
            pcall(function() trackedESPElements[id]:Destroy() end)
            trackedESPElements[id] = nil
        end
    end
    local tracersToRemove = {}
    for id in pairs(trackedTracers) do
        if string.sub(id, 1, string.len(prefix)) == prefix then
            table.insert(tracersToRemove, id)
        end
    end
    for _, id in ipairs(tracersToRemove) do
        if trackedTracers[id] then
            pcall(function() trackedTracers[id]:Remove() end)
            trackedTracers[id] = nil
        end
    end
    for _, c in ipairs(espFolder:GetChildren()) do
        if string.sub(c.Name, 1, string.len(prefix)) == prefix then
            pcall(function() c:Destroy() end)
        end
    end
end

local function getRootPart(char)
    if not char then return nil end
    return char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso") or char:FindFirstChildWhichIsA("BasePart")
end

local function getHumanoid(char)
    if not char then return nil end
    return char:FindFirstChildOfClass("Humanoid")
end

local function isPlayerAlive(p)
    if not p or not p.Character then return false end
    local hum = getHumanoid(p.Character)
    return hum ~= nil and hum.Health > 0
end

local function getPlayerRole(p)
    if not p then return "Innocent" end
    local bp = p:FindFirstChild("Backpack")
    local char = p.Character
    local knife = (bp and bp:FindFirstChild("Knife")) or (char and char:FindFirstChild("Knife"))
    local gun = (bp and bp:FindFirstChild("Gun")) or (char and char:FindFirstChild("Gun"))
    if knife then
        return "Murderer"
    elseif gun then
        return "Sheriff"
    end
    return "Innocent"
end

local function getRolePlayers()
    local murderer = nil
    local sheriff = nil
    local innocents = {}

    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isPlayerAlive(p) then
            local r = getPlayerRole(p)
            if r == "Murderer" then
                murderer = p
            elseif r == "Sheriff" then
                sheriff = p
            else
                table.insert(innocents, p)
            end
        end
    end
    return murderer, sheriff, innocents
end

local function getActiveMap()
    for _, c in ipairs(Workspace:GetChildren()) do
        if c:IsA("Model") and not string.find(string.lower(c.Name), "lobby") and not Players:GetPlayerFromCharacter(c) then
            if c:FindFirstChild("Spawns") or c:FindFirstChild("CoinAreas") or c:FindFirstChild("CoinContainer") or c:FindFirstChild("Base") then
                return c
            end
        end
    end
    return nil
end

local function getLobbyModel()
    for _, c in ipairs(Workspace:GetChildren()) do
        if c:IsA("Model") and string.find(string.lower(c.Name), "lobby") then
            return c
        end
    end
    return Workspace:FindFirstChild("SummerLobby") or Workspace:FindFirstChild("Lobby")
end

local function getAllActiveCoins()
    local coins = {}
    local seen = {}
    local CollectionService = game:GetService("CollectionService")

    for _, tag in ipairs({"CoinVisual", "Coin"}) do
        for _, v in ipairs(CollectionService:GetTagged(tag)) do
            if v and v.Parent and not v:GetAttribute("Collected") and not v:GetAttribute("Delete") then
                local part = v:IsA("BasePart") and v or v:FindFirstChildWhichIsA("BasePart")
                if part and not seen[part] and part.Transparency < 0.95 then
                    seen[part] = true
                    table.insert(coins, part)
                end
            end
        end
    end

    if #coins == 0 then
        local map = getActiveMap()
        if map then
            local container = map:FindFirstChild("CoinAreas") or map:FindFirstChild("CoinContainer") or map:FindFirstChild("Coins")
            if container then
                for _, c in ipairs(container:GetChildren()) do
                    for _, d in ipairs(c:GetDescendants()) do
                        if (d:GetAttribute("CoinID") or string.find(string.lower(d.Name), "coin")) and d:IsA("BasePart") and not seen[d] and d.Transparency < 0.95 then
                            seen[d] = true
                            table.insert(coins, d)
                        end
                    end
                    if (c:GetAttribute("CoinID") or string.find(string.lower(c.Name), "coin")) and c:IsA("BasePart") and not seen[c] and c.Transparency  4 then
            fcMoved = true
        end
        local vp = Camera.ViewportSize
        local nx = math.clamp(fcStartPos.X.Offset + delta.X, 0, math.max(vp.X - 46, 0))
        local ny = math.clamp(fcStartPos.Y.Offset + delta.Y, 0, math.max(vp.Y - 46, 0))
        floatingCrescent.Position = UDim2.new(0, nx, 0, ny)
    end
end)

floatingCrescent.MouseEnter:Connect(function()
    TweenService:Create(floatingCrescent, TweenInfo.new(0.15), {BackgroundColor3 = Colors.PurpleDark}):Play()
    fcCutout.BackgroundColor3 = Colors.PurpleDark
end)

floatingCrescent.MouseLeave:Connect(function()
    TweenService:Create(floatingCrescent, TweenInfo.new(0.15), {BackgroundColor3 = Colors.Background}):Play()
    fcCutout.BackgroundColor3 = Colors.Background
end)

floatingCrescent.MouseButton1Click:Connect(function()
    if fcMoved then
        fcMoved = false
        return
    end
    if ToggleUiVisibility then ToggleUiVisibility() end
end)

-- ---------------------------------------------------------------- Main window
local mainFrame = mk("Frame", {
    Name = "MainFrame",
    Size = UDim2.new(0, 660, 0, 440),
    Position = UDim2.new(0.5, -330, 0.5, -220),
    BackgroundColor3 = Colors.Background,
    BorderSizePixel = 0
}, screenGui)
addCorner(mainFrame, 12)

local mainStroke = addStroke(mainFrame, Color3.new(1, 1, 1), 1.5)
mk("UIGradient", {
    Color = ColorSequence.new(Colors.PurpleAccent, Colors.PurpleGlow),
    Rotation = 45
}, mainStroke)

local mainScale = mk("UIScale", {Scale = 1}, mainFrame)

-- Header
local titleBar = mk("Frame", {
    Name = "TitleBar",
    Size = UDim2.new(1, 0, 0, 46),
    BackgroundColor3 = Colors.SidebarBg,
    BorderSizePixel = 0
}, mainFrame)
addCorner(titleBar, 12)

mk("Frame", {
    Name = "BottomFill",
    Size = UDim2.new(1, 0, 0, 12),
    Position = UDim2.new(0, 0, 1, -12),
    BackgroundColor3 = Colors.SidebarBg,
    BorderSizePixel = 0
}, titleBar)

mk("Frame", {
    Size = UDim2.new(1, 0, 0, 1),
    Position = UDim2.new(0, 0, 1, -1),
    BackgroundColor3 = Colors.Divider,
    BorderSizePixel = 0
}, titleBar)

-- Logo (hilal)
local crescentContainer = mk("Frame", {
    Name = "LogoIcon",
    Size = UDim2.new(0, 26, 0, 26),
    Position = UDim2.new(0, 14, 0.5, -13),
    BackgroundTransparency = 1
}, titleBar)

local crescentOuter = mk("Frame", {
    Name = "Outer",
    Size = UDim2.new(0, 18, 0, 18),
    Position = UDim2.new(0.5, -9, 0.5, -9),
    BackgroundColor3 = Color3.new(1, 1, 1),
    BorderSizePixel = 0
}, crescentContainer)
addCorner(crescentOuter, 9)
mk("UIGradient", {Color = ColorSequence.new(Colors.PurpleAccent, Colors.PurpleGlow), Rotation = 90}, crescentOuter)

mk("Frame", {
    Name = "Cutout",
    Size = UDim2.new(0, 15, 0, 15),
    Position = UDim2.new(0.5, -4, 0.5, -13),
    BackgroundColor3 = Colors.SidebarBg,
    BorderSizePixel = 0,
    ZIndex = 2
}, crescentContainer)
addCorner(crescentContainer.Cutout, 8)

local brandTitle = mk("TextLabel", {
    Name = "BrandTitle",
    Size = UDim2.new(0, 80, 1, 0),
    Position = UDim2.new(0, 48, 0, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.GothamBold,
    Text = "LUNARIS",
    TextColor3 = Color3.new(1, 1, 1),
    TextSize = 15,
    TextXAlignment = Enum.TextXAlignment.Left
}, titleBar)
mk("UIGradient", {Color = ColorSequence.new(Colors.PurplePrimary, Colors.PurpleGlow)}, brandTitle)

local gamePill = mk("Frame", {
    Size = UDim2.new(0, 42, 0, 18),
    Position = UDim2.new(0, 132, 0.5, -9),
    BackgroundColor3 = Colors.PurpleDark,
    BorderSizePixel = 0
}, titleBar)
addCorner(gamePill, 9)
addStroke(gamePill, Colors.PurpleAccent, 1, 0.5)

local gameSubtitle = mk("TextLabel", {
    Name = "GameSubtitle",
    Size = UDim2.new(1, 0, 1, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.GothamBold,
    Text = "MM2",
    TextColor3 = Colors.PurplePrimary,
    TextSize = 10
}, gamePill)

-- Window controls
local winControls = mk("Frame", {
    Name = "WindowControls",
    Size = UDim2.new(0, 56, 1, 0),
    Position = UDim2.new(1, -68, 0, 0),
    BackgroundTransparency = 1
}, titleBar)

local minBtn = mk("TextButton", {
    Name = "Minimize",
    Size = UDim2.new(0, 24, 0, 24),
    Position = UDim2.new(0, 0, 0.5, -12),
    BackgroundColor3 = Colors.ControlBg,
    Font = Enum.Font.GothamBold,
    Text = "-",
    TextColor3 = Colors.TextMuted,
    TextSize = 14,
    AutoButtonColor = false,
    BorderSizePixel = 0
}, winControls)
addCorner(minBtn, 12)

local closeBtn = mk("TextButton", {
    Name = "Close",
    Size = UDim2.new(0, 24, 0, 24),
    Position = UDim2.new(0, 32, 0.5, -12),
    BackgroundColor3 = Colors.ControlBg,
    Font = Enum.Font.GothamBold,
    Text = "x",
    TextColor3 = Colors.AccentRed,
    TextSize = 13,
    AutoButtonColor = false,
    BorderSizePixel = 0
}, winControls)
addCorner(closeBtn, 12)

for _, b in ipairs({minBtn, closeBtn}) do
    local base = b.BackgroundColor3
    b.MouseEnter:Connect(function()
        TweenService:Create(b, TweenInfo.new(0.12), {BackgroundColor3 = Colors.BorderPurple}):Play()
    end)
    b.MouseLeave:Connect(function()
        TweenService:Create(b, TweenInfo.new(0.12), {BackgroundColor3 = base}):Play()
    end)
end

-- Search (في الهيدر)
local searchContainer = mk("Frame", {
    Size = UDim2.new(0, 190, 0, 28),
    Position = UDim2.new(1, -276, 0.5, -14),
    BackgroundColor3 = Colors.ControlBg,
    BorderSizePixel = 0
}, titleBar)
addCorner(searchContainer, 14)
local scStroke = addStroke(searchContainer, Colors.Divider, 1)

local searchBox = mk("TextBox", {
    Size = UDim2.new(1, -24, 1, 0),
    Position = UDim2.new(0, 12, 0, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.Gotham,
    PlaceholderText = "Search features...",
    PlaceholderColor3 = Colors.TextSubtle,
    Text = "",
    TextColor3 = Colors.TextPrimary,
    TextSize = 11,
    TextXAlignment = Enum.TextXAlignment.Left,
    ClearTextOnFocus = false
}, searchContainer)

searchBox.Focused:Connect(function()
    TweenService:Create(scStroke, TweenInfo.new(0.15), {Color = Colors.PurpleAccent}):Play()
end)
searchBox.FocusLost:Connect(function()
    TweenService:Create(scStroke, TweenInfo.new(0.15), {Color = Colors.Divider}):Play()
end)

-- Drag
local dragging = false
local dragInput, dragStart, startPos

titleBar.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        dragging = true
        dragStart = input.Position
        startPos = mainFrame.Position
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
    end
end)

titleBar.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        dragInput = input
    end
end)

UserInputService.InputChanged:Connect(function(input)
    if input == dragInput and dragging then
        local delta = input.Position - dragStart
        mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
    end
end)

-- Body = tab bar (أفقي) + content
local bodyFrame = mk("Frame", {
    Name = "Body",
    Size = UDim2.new(1, 0, 1, -70),
    Position = UDim2.new(0, 0, 0, 46),
    BackgroundTransparency = 1
}, mainFrame)

local tabBar = mk("Frame", {
    Name = "TabBar",
    Size = UDim2.new(1, 0, 0, 40),
    BackgroundTransparency = 1
}, bodyFrame)

mk("Frame", {
    Size = UDim2.new(1, -24, 0, 1),
    Position = UDim2.new(0, 12, 1, -1),
    BackgroundColor3 = Colors.Divider,
    BorderSizePixel = 0
}, tabBar)

local navList = mk("ScrollingFrame", {
    Name = "NavList",
    Size = UDim2.new(1, -24, 1, -2),
    Position = UDim2.new(0, 12, 0, 0),
    BackgroundTransparency = 1,
    BorderSizePixel = 0,
    ScrollBarThickness = 0,
    ScrollingDirection = Enum.ScrollingDirection.X,
    CanvasSize = UDim2.new(0, 0, 0, 0),
    AutomaticCanvasSize = Enum.AutomaticSize.X
}, tabBar)

mk("UIListLayout", {
    FillDirection = Enum.FillDirection.Horizontal,
    SortOrder = Enum.SortOrder.LayoutOrder,
    VerticalAlignment = Enum.VerticalAlignment.Center,
    Padding = UDim.new(0, 4)
}, navList)

local contentArea = mk("Frame", {
    Name = "ContentArea",
    Size = UDim2.new(1, 0, 1, -40),
    Position = UDim2.new(0, 0, 0, 40),
    BackgroundTransparency = 1
}, bodyFrame)

local tabFrames = {}
local navButtons = {}
local currentTab = "Home"

local tabNames = {"Home", "Combat", "Visuals", "Farm", "Survival", "Teleports", "Trolling", "Misc"}

local function createTabContent(name)
    local scroll = mk("ScrollingFrame", {
        Name = "Tab_" .. name,
        Size = UDim2.new(1, -20, 1, -12),
        Position = UDim2.new(0, 10, 0, 6),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        ScrollBarThickness = 3,
        ScrollBarImageColor3 = Colors.PurpleAccent,
        CanvasSize = UDim2.new(0, 0, 0, 0),
        AutomaticCanvasSize = Enum.AutomaticSize.Y,
        Visible = false
    }, contentArea)

    mk("UIListLayout", {SortOrder = Enum.SortOrder.LayoutOrder, Padding = UDim.new(0, 10)}, scroll)
    mk("UIPadding", {
        PaddingTop = UDim.new(0, 6),
        PaddingBottom = UDim.new(0, 10),
        PaddingLeft = UDim.new(0, 2),
        PaddingRight = UDim.new(0, 8)
    }, scroll)

    return scroll
end

local function switchTab(name)
    currentTab = name
    for tabName, frame in pairs(tabFrames) do
        frame.Visible = (tabName == name)
    end
    for tabName, btn in pairs(navButtons) do
        local isCurrent = (tabName == name)
        local indicator = btn:FindFirstChild("Indicator")
        if indicator then indicator.Visible = isCurrent end
        btn.BackgroundTransparency = isCurrent and 0 or 1
        btn.TextColor3 = isCurrent and Colors.PurplePrimary or Colors.TextMuted
    end
end

for idx, name in ipairs(tabNames) do
    tabFrames[name] = createTabContent(name)

    local btn = mk("TextButton", {
        Name = "Nav_" .. name,
        AutomaticSize = Enum.AutomaticSize.X,
        Size = UDim2.new(0, 0, 0, 28),
        BackgroundColor3 = Colors.ControlBg,
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        AutoButtonColor = false,
        Font = Enum.Font.GothamBold,
        Text = name,
        TextColor3 = Colors.TextMuted,
        TextSize = 12,
        LayoutOrder = idx
    }, navList)
    addCorner(btn, 8)
    mk("UIPadding", {PaddingLeft = UDim.new(0, 14), PaddingRight = UDim.new(0, 14)}, btn)

    local ind = mk("Frame", {
        Name = "Indicator",
        Size = UDim2.new(1, -16, 0, 2),
        Position = UDim2.new(0, 8, 1, -2),
        BackgroundColor3 = Colors.PurpleAccent,
        BorderSizePixel = 0,
        Visible = false
    }, btn)
    addCorner(ind, 1)

    btn.MouseEnter:Connect(function()
        if currentTab ~= name then
            btn.TextColor3 = Colors.TextPrimary
            TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundTransparency = 0.6}):Play()
        end
    end)

    btn.MouseLeave:Connect(function()
        if currentTab ~= name then
            btn.TextColor3 = Colors.TextMuted
            TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundTransparency = 1}):Play()
        end
    end)

    btn.MouseButton1Click:Connect(function()
        switchTab(name)
    end)

    navButtons[name] = btn
end

-- Footer
local footerBar = mk("Frame", {
    Name = "FooterBar",
    Size = UDim2.new(1, 0, 0, 24),
    Position = UDim2.new(0, 0, 1, -24),
    BackgroundColor3 = Colors.SidebarBg,
    BorderSizePixel = 0
}, mainFrame)
addCorner(footerBar, 12)

mk("Frame", {
    Name = "TopFill",
    Size = UDim2.new(1, 0, 0, 12),
    BackgroundColor3 = Colors.SidebarBg,
    BorderSizePixel = 0
}, footerBar)

mk("Frame", {
    Size = UDim2.new(1, 0, 0, 1),
    BackgroundColor3 = Colors.Divider,
    BorderSizePixel = 0
}, footerBar)

mk("TextLabel", {
    Size = UDim2.new(0, 330, 1, 0),
    Position = UDim2.new(0, 14, 0, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.Gotham,
    Text = "Lunaris v1.1  -  Murder Mystery 2  |  By Ahmed Shawky",
    TextColor3 = Colors.TextSubtle,
    TextSize = 10,
    TextXAlignment = Enum.TextXAlignment.Left
}, footerBar)

mk("TextLabel", {
    Size = UDim2.new(0, 250, 1, 0),
    Position = UDim2.new(1, -264, 0, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.Gotham,
    Text = "[L-CTRL] Menu  |  [P] Info  |  [END] Stop All",
    TextColor3 = Colors.TextSubtle,
    TextSize = 10,
    TextXAlignment = Enum.TextXAlignment.Right
}, footerBar)

-- ---------------------------------------------------------------- Components
local rowSearchIndex = {}

local function rowBase(parent, height)
    local row = mk("Frame", {
        Size = UDim2.new(1, 0, 0, height),
        BackgroundTransparency = 1,
        BorderSizePixel = 0
    }, parent)
    mk("Frame", {
        Name = "Divider",
        Size = UDim2.new(1, -28, 0, 1),
        Position = UDim2.new(0, 14, 1, -1),
        BackgroundColor3 = Colors.Divider,
        BorderSizePixel = 0
    }, row)
    return row
end

local function rowHeader(row, size, labelText, descText)
    local info = mk("Frame", {
        Size = size,
        Position = UDim2.new(0, 14, 0, 0),
        BackgroundTransparency = 1
    }, row)

    mk("TextLabel", {
        Size = UDim2.new(1, 0, 0, 16),
        Position = UDim2.new(0, 0, 0, 8),
        BackgroundTransparency = 1,
        Font = Enum.Font.GothamBold,
        Text = labelText,
        TextColor3 = Colors.TextPrimary,
        TextSize = 12,
        TextXAlignment = Enum.TextXAlignment.Left,
        TextTruncate = Enum.TextTruncate.AtEnd
    }, info)

    mk("TextLabel", {
        Size = UDim2.new(1, 0, 0, 14),
        Position = UDim2.new(0, 0, 0, 26),
        BackgroundTransparency = 1,
        Font = Enum.Font.Gotham,
        Text = descText,
        TextColor3 = Colors.TextSubtle,
        TextSize = 10,
        TextXAlignment = Enum.TextXAlignment.Left,
        TextTruncate = Enum.TextTruncate.AtEnd
    }, info)
end

local function createCategoryHeader(parent, text)
    local hdr = mk("Frame", {Size = UDim2.new(1, 0, 0, 24), BackgroundTransparency = 1}, parent)

    local dot = mk("Frame", {
        Size = UDim2.new(0, 6, 0, 6),
        Position = UDim2.new(0, 4, 0.5, -3),
        BackgroundColor3 = Colors.PurpleGlow,
        BorderSizePixel = 0
    }, hdr)
    addCorner(dot, 3)

    mk("TextLabel", {
        Size = UDim2.new(1, -20, 1, 0),
        Position = UDim2.new(0, 16, 0, 0),
        BackgroundTransparency = 1,
        Font = Enum.Font.GothamBold,
        Text = string.upper(text),
        TextColor3 = Colors.PurpleMuted,
        TextSize = 10,
        TextXAlignment = Enum.TextXAlignment.Left
    }, hdr)

    return hdr
end

local function createCardGroup(parent)
    local card = mk("Frame", {
        Size = UDim2.new(1, 0, 0, 0),
        AutomaticSize = Enum.AutomaticSize.Y,
        BackgroundColor3 = Colors.CardBg,
        BorderSizePixel = 0
    }, parent)
    addCorner(card, 12)
    addStroke(card, Colors.Divider, 1)
    mk("UIListLayout", {SortOrder = Enum.SortOrder.LayoutOrder, Padding = UDim.new(0, 0)}, card)
    return card
end

local function createToggleRow(parent, labelText, descText, defaultState, callback, registerSearch)
    local row = rowBase(parent, 46)
    rowHeader(row, UDim2.new(1, -72, 1, 0), labelText, descText)

    local toggleTrack = mk("TextButton", {
        Size = UDim2.new(0, 38, 0, 20),
        Position = UDim2.new(1, -52, 0.5, -10),
        BackgroundColor3 = defaultState and Colors.PurpleAccent or Colors.ControlBg,
        BorderSizePixel = 0,
        Text = "",
        AutoButtonColor = false
    }, row)
    addCorner(toggleTrack, 10)

    local knob = mk("Frame", {
        Size = UDim2.new(0, 16, 0, 16),
        Position = defaultState and UDim2.new(1, -18, 0.5, -8) or UDim2.new(0, 2, 0.5, -8),
        BackgroundColor3 = Colors.TextPrimary,
        BorderSizePixel = 0
    }, toggleTrack)
    addCorner(knob, 8)

    local state = defaultState
    local function SetState(newState)
        state = newState
        TweenService:Create(toggleTrack, TweenInfo.new(0.18, Enum.EasingStyle.Quad), {
            BackgroundColor3 = state and Colors.PurpleAccent or Colors.ControlBg
        }):Play()
        TweenService:Create(knob, TweenInfo.new(0.18, Enum.EasingStyle.Quad), {
            Position = state and UDim2.new(1, -18, 0.5, -8) or UDim2.new(0, 2, 0.5, -8)
        }):Play()
        if callback then callback(state) end
        if not isSyncingUI and AutoSaveConfig then AutoSaveConfig() end
    end

    toggleTrack.MouseButton1Click:Connect(function()
        SetState(not state)
    end)

    if registerSearch then
        table.insert(rowSearchIndex, {frame = row, query = string.lower(labelText .. " " .. descText)})
    end

    return {Row = row, SetState = SetState, GetState = function() return state end}
end

local function createSliderRow(parent, labelText, descText, minVal, maxVal, defaultVal, isFloat, unit, callback, registerSearch)
    local row = rowBase(parent, 50)
    rowHeader(row, UDim2.new(0.5, -14, 1, 0), labelText, descText)

    local sliderContainer = mk("Frame", {
        Size = UDim2.new(0.44, 0, 1, 0),
        Position = UDim2.new(0.54, 0, 0, 0),
        BackgroundTransparency = 1
    }, row)

    local valLbl = mk("TextLabel", {
        Size = UDim2.new(1, -16, 0, 16),
        Position = UDim2.new(0, 0, 0, 8),
        BackgroundTransparency = 1,
        Font = Enum.Font.GothamBold,
        Text = tostring(defaultVal) .. (unit or ""),
        TextColor3 = Colors.PurplePrimary,
        TextSize = 11,
        TextXAlignment = Enum.TextXAlignment.Right
    }, sliderContainer)

    local track = mk("Frame", {
        Size = UDim2.new(1, -16, 0, 6),
        Position = UDim2.new(0, 0, 0, 30),
        BackgroundColor3 = Colors.ControlBg,
        BorderSizePixel = 0
    }, sliderContainer)
    addCorner(track, 3)

    local pct = math.clamp((defaultVal - minVal) / (maxVal - minVal), 0, 1)

    local fill = mk("Frame", {
        Size = UDim2.new(pct, 0, 1, 0),
        BackgroundColor3 = Colors.PurpleAccent,
        BorderSizePixel = 0
    }, track)
    addCorner(fill, 3)
    mk("UIGradient", {Color = ColorSequence.new(Colors.PurpleAccent, Colors.PurpleGlow)}, fill)

    local thumb = mk("Frame", {
        Size = UDim2.new(0, 12, 0, 12),
        Position = UDim2.new(pct, -6, 0.5, -6),
        BackgroundColor3 = Colors.TextPrimary,
        BorderSizePixel = 0,
        ZIndex = 2
    }, track)
    addCorner(thumb, 6)
    addStroke(thumb, Colors.PurpleAccent, 2)

    local curVal = defaultVal
    local sliding = false

    local function updateValueFromX(x)
        local rel = math.clamp((x - track.AbsolutePosition.X) / track.AbsoluteSize.X, 0, 1)
        fill.Size = UDim2.new(rel, 0, 1, 0)
        thumb.Position = UDim2.new(rel, -6, 0.5, -6)
        local raw = minVal + rel * (maxVal - minVal)
        curVal = isFloat and math.floor(raw * 100) / 100 or math.floor(raw + 0.5)
        valLbl.Text = tostring(curVal) .. (unit or "")
        if callback then callback(curVal) end
        if not isSyncingUI and AutoSaveConfig then AutoSaveConfig() end
    end

    track.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            sliding = true
            updateValueFromX(input.Position.X)
        end
    end)

    UserInputService.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            sliding = false
        end
    end)

    UserInputService.InputChanged:Connect(function(input)
        if sliding and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
            updateValueFromX(input.Position.X)
        end
    end)

    local function SetValue(v)
        curVal = math.clamp(v, minVal, maxVal)
        local r = (curVal - minVal) / (maxVal - minVal)
        fill.Size = UDim2.new(r, 0, 1, 0)
        thumb.Position = UDim2.new(r, -6, 0.5, -6)
        valLbl.Text = tostring(curVal) .. (unit or "")
        if callback then callback(curVal) end
    end

    if registerSearch then
        table.insert(rowSearchIndex, {frame = row, query = string.lower(labelText .. " " .. descText)})
    end

    return {Row = row, SetValue = SetValue, GetValue = function() return curVal end}
end

local function createDropdownRow(parent, labelText, descText, options, defaultOption, callback, registerSearch)
    local row = rowBase(parent, 50)
    rowHeader(row, UDim2.new(0.55, -14, 1, 0), labelText, descText)

    local dropBtn = mk("TextButton", {
        Size = UDim2.new(0, 116, 0, 26),
        Position = UDim2.new(1, -130, 0.5, -13),
        BackgroundColor3 = Colors.ControlBg,
        BorderSizePixel = 0,
        AutoButtonColor = false,
        Font = Enum.Font.GothamBold,
        Text = tostring(defaultOption) .. "  v",
        TextColor3 = Colors.PurplePrimary,
        TextSize = 11
    }, row)
    addCorner(dropBtn, 8)
    local dStroke = addStroke(dropBtn, Colors.Divider, 1)

    dropBtn.MouseEnter:Connect(function()
        TweenService:Create(dStroke, TweenInfo.new(0.12), {Color = Colors.PurpleAccent}):Play()
    end)
    dropBtn.MouseLeave:Connect(function()
        TweenService:Create(dStroke, TweenInfo.new(0.12), {Color = Colors.Divider}):Play()
    end)

    local selected = defaultOption
    local optIndex = 1
    for i, opt in ipairs(options) do
        if opt == defaultOption then
            optIndex = i
            break
        end
    end

    dropBtn.MouseButton1Click:Connect(function()
        optIndex = optIndex + 1
        if optIndex > #options then optIndex = 1 end
        selected = options[optIndex]
        dropBtn.Text = tostring(selected) .. "  v"
        if callback then callback(selected) end
        if not isSyncingUI and AutoSaveConfig then AutoSaveConfig() end
    end)

    local function SetSelected(opt)
        selected = opt
        for i, o in ipairs(options) do
            if o == opt then
                optIndex = i
                break
            end
        end
        dropBtn.Text = tostring(selected) .. "  v"
        if callback then callback(selected) end
    end

    local function UpdateOptions(newOptions)
        options = newOptions
        optIndex = 1
        if #options > 0 then
            selected = options[1]
            dropBtn.Text = tostring(selected) .. "  v"
        end
    end

    if registerSearch then
        table.insert(rowSearchIndex, {frame = row, query = string.lower(labelText .. " " .. descText)})
    end

    return {Row = row, SetSelected = SetSelected, UpdateOptions = UpdateOptions, GetSelected = function() return selected end}
end

local function createButtonRow(parent, labelText, btnText, descText, callback, registerSearch)
    local row = rowBase(parent, 46)
    rowHeader(row, UDim2.new(1, -130, 1, 0), labelText, descText)

    local btn = mk("TextButton", {
        Size = UDim2.new(0, 92, 0, 26),
        Position = UDim2.new(1, -106, 0.5, -13),
        BackgroundColor3 = Colors.PurpleDark,
        BorderSizePixel = 0,
        AutoButtonColor = false,
        Font = Enum.Font.GothamBold,
        Text = btnText,
        TextColor3 = Colors.PurplePrimary,
        TextSize = 11
    }, row)
    addCorner(btn, 8)
    local bStroke = addStroke(btn, Colors.PurpleAccent, 1, 0.5)

    btn.MouseEnter:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Colors.PurpleAccent, TextColor3 = Colors.Background}):Play()
        TweenService:Create(bStroke, TweenInfo.new(0.12), {Transparency = 0}):Play()
    end)
    btn.MouseLeave:Connect(function()
        TweenService:Create(btn, TweenInfo.new(0.12), {BackgroundColor3 = Colors.PurpleDark, TextColor3 = Colors.PurplePrimary}):Play()
        TweenService:Create(bStroke, TweenInfo.new(0.12), {Transparency = 0.5}):Play()
    end)

    btn.MouseButton1Click:Connect(callback)

    if registerSearch then
        table.insert(rowSearchIndex, {frame = row, query = string.lower(labelText .. " " .. descText)})
    end

    return row
end

local function createInfoRow(parent, labelText, valueText, registerSearch)
    local row = rowBase(parent, 36)

    mk("TextLabel", {
        Size = UDim2.new(0.45, 0, 1, 0),
        Position = UDim2.new(0, 14, 0, 0),
        BackgroundTransparency = 1,
        Font = Enum.Font.GothamBold,
        Text = labelText,
        TextColor3 = Colors.TextMuted,
        TextSize = 11,
        TextXAlignment = Enum.TextXAlignment.Left
    }, row)

    local valLbl = mk("TextLabel", {
        Size = UDim2.new(0.5, 0, 1, 0),
        Position = UDim2.new(0.5, -14, 0, 0),
        BackgroundTransparency = 1,
        Font = Enum.Font.GothamBold,
        Text = valueText,
        TextColor3 = Colors.PurplePrimary,
        TextSize = 11,
        TextXAlignment = Enum.TextXAlignment.Right
    }, row)

    if registerSearch then
        table.insert(rowSearchIndex, {frame = row, query = string.lower(labelText)})
    end

    return {
        Row = row,
        SetValue = function(newVal) valLbl.Text = tostring(newVal) end,
        SetColor = function(newCol) valLbl.TextColor3 = newCol end
    }
end



local banner = mk("Frame", {
    Name = "WelcomeBanner",
    Size = UDim2.new(1, 0, 0, 84),
    BackgroundColor3 = Color3.new(1, 1, 1),
    BorderSizePixel = 0
}, tabFrames.Home)
addCorner(banner, 12)
mk("UIGradient", {Color = ColorSequence.new(Colors.PurpleDark, Colors.CardBg), Rotation = 20}, banner)
addStroke(banner, Colors.PurpleAccent, 1, 0.6)

local bannerTitle = mk("TextLabel", {
    Size = UDim2.new(1, -32, 0, 30),
    Position = UDim2.new(0, 18, 0, 12),
    BackgroundTransparency = 1,
    Font = Enum.Font.GothamBold,
    Text = "LUNARIS",
    TextColor3 = Color3.new(1, 1, 1),
    TextSize = 24,
    TextXAlignment = Enum.TextXAlignment.Left
}, banner)
mk("UIGradient", {Color = ColorSequence.new(Colors.PurplePrimary, Colors.PurpleGlow)}, bannerTitle)

mk("TextLabel", {
    Size = UDim2.new(1, -32, 0, 14),
    Position = UDim2.new(0, 18, 0, 44),
    BackgroundTransparency = 1,
    Font = Enum.Font.GothamBold,
    Text = "By Ahmed Shawky",
    TextColor3 = Colors.TextPrimary,
    TextSize = 11,
    TextXAlignment = Enum.TextXAlignment.Left
}, banner)

mk("TextLabel", {
    Size = UDim2.new(1, -32, 0, 12),
    Position = UDim2.new(0, 18, 0, 60),
    BackgroundTransparency = 1,
    Font = Enum.Font.Gotham,
    Text = "t.me/ix_ahmed_x   |   Press P for contact info",
    TextColor3 = Colors.TextMuted,
    TextSize = 10,
    TextXAlignment = Enum.TextXAlignment.Left
}, banner)

local versionChip = mk("Frame", {
    Size = UDim2.new(0, 46, 0, 20),
    Position = UDim2.new(1, -62, 0, 14),
    BackgroundColor3 = Colors.Background,
    BorderSizePixel = 0
}, banner)
addCorner(versionChip, 10)
addStroke(versionChip, Colors.PurpleAccent, 1, 0.4)
mk("TextLabel", {
    Size = UDim2.new(1, 0, 1, 0),
    BackgroundTransparency = 1,
    Font = Enum.Font.GothamBold,
    Text = "v1.1",
    TextColor3 = Colors.PurplePrimary,
    TextSize = 10
}, versionChip)




createCategoryHeader(tabFrames.Home, "Round Status & Roles")
local homeRoundCard = createCardGroup(tabFrames.Home)
local statusRoundRow = createInfoRow(homeRoundCard, "Round State", "Waiting...", true)
local timerRoundRow = createInfoRow(homeRoundCard, "Time Remaining", "0:00", true)
local murdererRow = createInfoRow(homeRoundCard, "Murderer", "Undetected", true)
local sheriffRow = createInfoRow(homeRoundCard, "Sheriff", "Undetected", true)
murdererRow.SetColor(Colors.AccentRed)
sheriffRow.SetColor(Colors.AccentBlue)

createCategoryHeader(tabFrames.Home, "Quick Actions")
local homeActionCard = createCardGroup(tabFrames.Home)

createButtonRow(homeActionCard, "Shoot Murderer", "SHOOT", "Instantly equips gun and shoots murderer", function()
    local murderer = nil
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isPlayerAlive(p) and getPlayerRole(p) == "Murderer" then
            murderer = p
            break
        end
    end

    local char = LocalPlayer.Character
    local bp = LocalPlayer:FindFirstChild("Backpack")
    local gun = (bp and bp:FindFirstChild("Gun")) or (char and char:FindFirstChild("Gun"))
    if not gun then
        SendNotification("Lunaris", "You do not have the Gun!", 2)
        return
    end
    if not murderer or not murderer.Character then
        SendNotification("Lunaris", "Murderer not found or deceased!", 2)
        return
    end

    local hum = getHumanoid(char)
    if hum and bp and gun.Parent == bp then
        hum:EquipTool(gun)
        task.wait(0.1)
    end

    local root = getRootPart(char)
    local mRoot = getRootPart(murderer.Character)
    if root and mRoot and gun:FindFirstChild("Shoot") then
        local rayAtt = root:FindFirstChild("GunRaycastAttachment")
        local origin = rayAtt and rayAtt.WorldCFrame or root.CFrame
        local targetCF = CFrame.new(mRoot.Position)
        gun.Shoot:FireServer(origin, targetCF)
        SendNotification("Lunaris", "Shot fired at Murderer (" .. murderer.Name .. ")!", 2)
    end
end, true)

createButtonRow(homeActionCard, "Grab Gun", "GRAB", "Teleports to dropped gun or picks it up", function()
    local drop = getGunDrop()
    local gunPart = getGunDropPart(drop)
    local char = LocalPlayer.Character
    local root = getRootPart(char)
    if not gunPart then
        SendNotification("Lunaris", "No Gun is currently dropped on map!", 2)
        return
    end
    if root then
        root.CFrame = gunPart.CFrame * CFrame.new(0, 1.5, 0)
        task.wait(0.05)
        interactWithGunDrop(gunPart, drop)
        SendNotification("Lunaris", "Grabbed dropped gun!", 2)
    end
end, true)

createButtonRow(homeActionCard, "Announce Roles", "CHAT", "Announces Murderer & Sheriff in public chat", function()
    local murderer, sheriff = getRolePlayers()
    local msg = "[Identical] "
    if murderer then
        msg = msg .. "Murderer: " .. murderer.Name .. " | "
    else
        msg = msg .. "Murderer: Unknown | "
    end
    if sheriff then
        msg = msg .. "Sheriff: " .. sheriff.Name
    else
        msg = msg .. "Sheriff: Unknown"
    end

    local textChannels = TextChatService:FindFirstChild("TextChannels")
    local rbxGeneral = textChannels and textChannels:FindFirstChild("RBXGeneral")
    if rbxGeneral and rbxGeneral.SendAsync then
        rbxGeneral:SendAsync(msg)
    else
        pcall(function()
            local events = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
            local sayReq = events and events:FindFirstChild("SayMessageRequest")
            if sayReq then
                sayReq:FireServer(msg, "All")
            end
        end)
    end
    SendNotification("Lunaris", "Roles announced in chat!", 2)
end, true)

createButtonRow(homeActionCard, "Copy Death List", "COPY", "Copies deceased players this round to clipboard", function()
    if #deadPlayersList == 0 then
        SendNotification("Lunaris", "No recorded deaths yet this round.", 2)
        return
    end
    local text = "MM2 Dead Players: " .. table.concat(deadPlayersList, ", ")
    if setclipboard then
        setclipboard(text)
        SendNotification("Lunaris", "Death list copied to clipboard!", 2)
    else
        SendNotification("Lunaris", "Clipboard API not supported.", 2)
    end
end, true)

createCategoryHeader(tabFrames.Home, "Configuration Profile")
local cfgCard = createCardGroup(tabFrames.Home)

createButtonRow(cfgCard, "Save Configuration", "SAVE", "Writes all current settings to disk", function()
    AutoSaveConfig()
    SendNotification("Lunaris", "Configuration profile saved to disk!", 2)
end, true)

createButtonRow(cfgCard, "Reload Configuration", "LOAD", "Restores saved settings profile from disk", function()
    if LoadSavedConfig() then
        if SyncUIWithConfig then SyncUIWithConfig() end
        SendNotification("Lunaris", "Configuration profile restored!", 2)
    else
        SendNotification("Lunaris", "No saved profile found.", 2)
    end
end, true)

createButtonRow(cfgCard, "Reset Defaults", "RESET", "Restores all settings to default values", function()
    for k, v in pairs(DefaultConfig) do
        Config[k] = v
    end
    if SyncUIWithConfig then SyncUIWithConfig() end
    AutoSaveConfig()
    SendNotification("Lunaris", "Settings reset to defaults!", 2)
end, true)

createCategoryHeader(tabFrames.Combat, "Sheriff & Gun")
local gunCard = createCardGroup(tabFrames.Combat)

ctrls.AutoShoot = createToggleRow(gunCard, "Auto Shoot Murderer", "Automatically fires revolver at Murderer in sight", Config.AutoShoot, function(v)
    Config.AutoShoot = v
end, true)

ctrls.SilentAim = createToggleRow(gunCard, "Silent Aim", "Redirects shot raycast directly to target hitbox", Config.SilentAim, function(v)
    Config.SilentAim = v
end, true)

ctrls.AimPrediction = createToggleRow(gunCard, "Aim Prediction", "Compensates for target velocity & movement", Config.AimPrediction, function(v)
    Config.AimPrediction = v
end, true)

ctrls.PingComp = createToggleRow(gunCard, "Ping Compensation", "Adjusts bullet lead time according to player ping", Config.PingComp, function(v)
    Config.PingComp = v
end, true)

ctrls.SingleShot = createToggleRow(gunCard, "Single Shot Lock", "Fires one verified shot and halts until next reset", Config.SingleShot, function(v)
    Config.SingleShot = v
end, true)

ctrls.AutoEquipGun = createToggleRow(gunCard, "Auto Equip Gun", "Pulls out revolver when Murderer is within range", Config.AutoEquipGun, function(v)
    Config.AutoEquipGun = v
end, true)

ctrls.GrabGunAuto = createToggleRow(gunCard, "Full Gun Grabber", "Automatically collects dropped gun immediately", Config.GrabGunAuto, function(v)
    Config.GrabGunAuto = v
end, true)

ctrls.ShowFOV = createToggleRow(gunCard, "Show FOV Circle", "Draws FOV circle on screen for aimbot", Config.ShowFOV, function(v)
    Config.ShowFOV = v
end, true)

ctrls.FOVRadius = createSliderRow(gunCard, "FOV Radius", "Radius of aimbot lock target field", 50, 700, Config.FOVRadius, false, " px", function(v)
    Config.FOVRadius = v
end, true)

createCategoryHeader(tabFrames.Combat, "Murderer & Knife")
local knifeCard = createCardGroup(tabFrames.Combat)

ctrls.KillAura = createToggleRow(knifeCard, "Kill Aura", "Automatically strikes any player inside aura reach", Config.KillAura, function(v)
    Config.KillAura = v
end, true)

ctrls.AutoKill = createToggleRow(knifeCard, "Auto Kill Innocents", "Constantly eliminates innocents with knife", Config.AutoKill, function(v)
    Config.AutoKill = v
end, true)

ctrls.KillMode = createDropdownRow(knifeCard, "Kill Mode", "Method used for knife strikes", {"Legit", "Blatant", "Throw"}, Config.KillMode, function(v)
    Config.KillMode = v
end, true)

ctrls.KnifeSilentAim = createToggleRow(knifeCard, "Knife Silent Aim", "Redirects thrown knives directly into target players", Config.KnifeSilentAim, function(v)
    Config.KnifeSilentAim = v
end, true)

ctrls.KillAll = createToggleRow(knifeCard, "Kill All (No Limit)", "Eliminates all remaining living players instantly", Config.KillAll, function(v)
    Config.KillAll = v
end, true)

ctrls.AuraRange = createSliderRow(knifeCard, "Aura Range", "Distance threshold for melee knife strikes", 5, 45, Config.AuraRange, false, " studs", function(v)
    Config.AuraRange = v
end, true)

ctrls.ShowAuraRing = createToggleRow(knifeCard, "Show Aura Ring", "Draws visual indicator ring around character", Config.ShowAuraRing, function(v)
    Config.ShowAuraRing = v
end, true)

ctrls.AutoEquipKnife = createToggleRow(knifeCard, "Auto Equip Knife", "Equips knife automatically when targets in range", Config.AutoEquipKnife, function(v)
    Config.AutoEquipKnife = v
end, true)

ctrls.ProximityKnife = createToggleRow(knifeCard, "Proximity Knife", "Pre-emptively draws blade when enemy nears", Config.ProximityKnife, function(v)
    Config.ProximityKnife = v
end, true)

createCategoryHeader(tabFrames.Combat, "Hitbox Expansion & Stalker")
local hitboxCard = createCardGroup(tabFrames.Combat)

ctrls.HitboxExpander = createToggleRow(hitboxCard, "Hitbox Expander", "Expands player root hitboxes for easy stabs/shots", Config.HitboxExpander, function(v)
    Config.HitboxExpander = v
    if not v then
        for part, sz in pairs(originalHitboxSizes) do
            if part and part.Parent then
                part.Size = sz
                part.Transparency = 1
            end
        end
        originalHitboxSizes = {}
    end
end, true)

ctrls.HitboxSize = createSliderRow(hitboxCard, "Hitbox Size", "Expanded size multiplier for hitboxes", 4, 30, Config.HitboxSize, false, " studs", function(v)
    Config.HitboxSize = v
end, true)

ctrls.FollowMurderer = createToggleRow(hitboxCard, "Murderer Follow", "Maintains safe following position behind Murderer", Config.FollowMurderer, function(v)
    Config.FollowMurderer = v
end, true)

ctrls.FollowDist = createSliderRow(hitboxCard, "Follow Offset", "Distance maintained while following Murderer", 8, 40, Config.FollowDist, false, " studs", function(v)
    Config.FollowDist = v
end, true)

createCategoryHeader(tabFrames.Visuals, "Full Role ESP")
local espRoleCard = createCardGroup(tabFrames.Visuals)

ctrls.RoleESP = createToggleRow(espRoleCard, "Role ESP Enabled", "Master toggle for character role highlights", Config.RoleESP, function(v)
    Config.RoleESP = v
    if not v then clearESPCategory("mm2_") end
end, true)

ctrls.ESPChams = createToggleRow(espRoleCard, "Chams (3D Highlight)", "Renders solid 3D glowing color chams", Config.ESPChams, function(v)
    Config.ESPChams = v
    if not v then clearESPCategory("cham_") end
end, true)

ctrls.ESPBoxes = createToggleRow(espRoleCard, "Player Boxes", "Draws bounding box around target players", Config.ESPBoxes, function(v)
    Config.ESPBoxes = v
end, true)

ctrls.ESPNames = createToggleRow(espRoleCard, "Role Tags & Names", "Displays overhead role tags and player names", Config.ESPNames, function(v)
    Config.ESPNames = v
end, true)

ctrls.ESPDistance = createToggleRow(espRoleCard, "Distance Labels", "Displays distance in studs to each player", Config.ESPDistance, function(v)
    Config.ESPDistance = v
end, true)

ctrls.ESPTracers = createToggleRow(espRoleCard, "Snapline Tracers", "Draws tracers from under character to targets", Config.ESPTracers, function(v)
    Config.ESPTracers = v
    if not v then
        for _, line in pairs(trackedTracers) do
            if line then line.Visible = false end
        end
    end
end, true)

ctrls.ESPDistanceMax = createSliderRow(espRoleCard, "Max ESP Distance", "Maximum render distance for highlights", 50, 1000, Config.ESPDistanceMax, false, " studs", function(v)
    Config.ESPDistanceMax = v
end, true)

createCategoryHeader(tabFrames.Visuals, "Item & World Highlights")
local espItemCard = createCardGroup(tabFrames.Visuals)

ctrls.GunESP = createToggleRow(espItemCard, "Dropped Gun ESP", "Highlights dropped revolver when Sheriff falls", Config.GunESP, function(v)
    Config.GunESP = v
    if not v then clearESPCategory("gun_") end
end, true)

ctrls.CoinESP = createToggleRow(espItemCard, "Coin ESP", "Highlights active coin spawns across map", Config.CoinESP, function(v)
    Config.CoinESP = v
    if not v then clearESPCategory("coin_") end
end, true)

createCategoryHeader(tabFrames.Farm, "Coin Farming")
local farmCard = createCardGroup(tabFrames.Farm)

ctrls.CoinFarm = createToggleRow(farmCard, "Auto Farm Coins", "Automatically collects all active coins on map", Config.CoinFarm, function(v)
    Config.CoinFarm = v
end, true)

ctrls.FarmMethod = createDropdownRow(farmCard, "Movement Method", "Navigation method to reach coin positions", {"Glide", "Tween", "Walk"}, Config.FarmMethod, function(v)
    Config.FarmMethod = v
end, true)

ctrls.FarmSpeed = createSliderRow(farmCard, "Farm Speed", "Movement speed while farming coins", 16, 60, Config.FarmSpeed, false, " studs/s", function(v)
    Config.FarmSpeed = v
end, true)

ctrls.SafeCoinFarm = createToggleRow(farmCard, "Safe Farming", "Avoids coins within Murderer danger radius", Config.SafeCoinFarm, function(v)
    Config.SafeCoinFarm = v
end, true)

ctrls.BagFullStop = createToggleRow(farmCard, "Bag Full Stop", "Halts farming once 40-coin bag limit is met", Config.BagFullStop, function(v)
    Config.BagFullStop = v
end, true)

ctrls.QuickFarm = createToggleRow(farmCard, "Quick Mode", "High velocity rapid coin sweep", Config.QuickFarm, function(v)
    Config.QuickFarm = v
end, true)

createCategoryHeader(tabFrames.Survival, "Murderer Avoidance & Auto-Play")
local survCard = createCardGroup(tabFrames.Survival)

ctrls.MurdererAvoid = createToggleRow(survCard, "Murderer Avoidance", "Automatically maneuvers away from active Murderer", Config.MurdererAvoid, function(v)
    Config.MurdererAvoid = v
end, true)

ctrls.SafetyRadius = createSliderRow(survCard, "Safety Radius", "Minimum distance maintained from Murderer", 20, 80, Config.SafetyRadius, false, " studs", function(v)
    Config.SafetyRadius = v
end, true)

ctrls.RetreatToLobby = createToggleRow(survCard, "Retreat to Lobby", "Teleports to lobby if Murderer gets too close", Config.RetreatToLobby, function(v)
    Config.RetreatToLobby = v
end, true)

ctrls.ProximityAlert = createToggleRow(survCard, "Proximity Alert", "Warns on screen when Murderer approaches", Config.ProximityAlert, function(v)
    Config.ProximityAlert = v
end, true)

ctrls.SprintWhenChased = createToggleRow(survCard, "Sprint When Chased", "Increases walk speed when Murderer is near", Config.SprintWhenChased, function(v)
    Config.SprintWhenChased = v
end, true)

ctrls.AutoPlay = createToggleRow(survCard, "Role-Based Auto Play", "Automates actions according to assigned role", Config.AutoPlay, function(v)
    Config.AutoPlay = v
end, true)

createCategoryHeader(tabFrames.Teleports, "Map & Role Navigation")
local tpCard = createCardGroup(tabFrames.Teleports)

createButtonRow(tpCard, "Teleport to Murderer", "GOTO", "Teleports behind the active Murderer", function()
    local murderer = nil
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isPlayerAlive(p) and getPlayerRole(p) == "Murderer" then
            murderer = p
            break
        end
    end
    local root = getRootPart(LocalPlayer.Character)
    if murderer and murderer.Character and root then
        local mRoot = getRootPart(murderer.Character)
        if mRoot then
            root.CFrame = mRoot.CFrame * CFrame.new(0, 0, 4)
            SendNotification("Lunaris", "Teleported to Murderer (" .. murderer.Name .. ")", 2)
        end
    else
        SendNotification("Lunaris", "Murderer not found or deceased.", 2)
    end
end, true)

createButtonRow(tpCard, "Teleport to Sheriff", "GOTO", "Teleports next to the active Sheriff", function()
    local sheriff = nil
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isPlayerAlive(p) and getPlayerRole(p) == "Sheriff" then
            sheriff = p
            break
        end
    end
    local root = getRootPart(LocalPlayer.Character)
    if sheriff and sheriff.Character and root then
        local sRoot = getRootPart(sheriff.Character)
        if sRoot then
            root.CFrame = sRoot.CFrame * CFrame.new(0, 0, 4)
            SendNotification("Lunaris", "Teleported to Sheriff (" .. sheriff.Name .. ")", 2)
        end
    else
        SendNotification("Lunaris", "Sheriff not found or deceased.", 2)
    end
end, true)

createButtonRow(tpCard, "Teleport to Active Map", "GOTO", "Teleports to match map spawns", function()
    local map = getActiveMap()
    local root = getRootPart(LocalPlayer.Character)
    if map and root then
        local spawns = map:FindFirstChild("Spawns")
        if spawns and #spawns:GetChildren() > 0 then
            local sp = spawns:GetChildren()[1]
            root.CFrame = sp.CFrame * CFrame.new(0, 3, 0)
        else
            local p = map:FindFirstChildWhichIsA("BasePart")
            if p then root.CFrame = p.CFrame * CFrame.new(0, 5, 0) end
        end
        SendNotification("Lunaris", "Teleported to " .. map.Name, 2)
    else
        SendNotification("Lunaris", "No active map currently found.", 2)
    end
end, true)

createButtonRow(tpCard, "Teleport to Lobby", "GOTO", "Teleports into the lobby safe area", function()
    local lobby = getLobbyModel()
    local root = getRootPart(LocalPlayer.Character)
    if lobby and root then
        local p = lobby:FindFirstChild("Spawns") or lobby:FindFirstChildWhichIsA("BasePart")
        if p then
            local targetPart = p:IsA("Model") and p:GetChildren()[1] or p
            if targetPart then root.CFrame = targetPart.CFrame * CFrame.new(0, 3, 0) end
        end
        SendNotification("Lunaris", "Teleported to Lobby", 2)
    end
end, true)

ctrls.AutoDrop = createToggleRow(tpCard, "Auto Drop at Round Start", "Drops into map immediately when round starts", Config.AutoDrop, function(v)
    Config.AutoDrop = v
end, true)

createCategoryHeader(tabFrames.Teleports, "Saved Coordinates")
local saveCard = createCardGroup(tabFrames.Teleports)

createButtonRow(saveCard, "Save Location 1", "SAVE 1", "Stores current position in Slot 1", function()
    local root = getRootPart(LocalPlayer.Character)
    if root then
        Config.SaveSlot1 = root.CFrame
        AutoSaveConfig()
        SendNotification("Lunaris", "Saved Slot 1 position to disk.", 2)
    end
end, true)

createButtonRow(saveCard, "Teleport Location 1", "GOTO 1", "Teleports back to Slot 1 position", function()
    local root = getRootPart(LocalPlayer.Character)
    if root and Config.SaveSlot1 then
        root.CFrame = Config.SaveSlot1
        SendNotification("Lunaris", "Teleported to Slot 1.", 2)
    else
        SendNotification("Lunaris", "No location saved in Slot 1.", 2)
    end
end, true)

createButtonRow(saveCard, "Save Location 2", "SAVE 2", "Stores current position in Slot 2", function()
    local root = getRootPart(LocalPlayer.Character)
    if root then
        Config.SaveSlot2 = root.CFrame
        AutoSaveConfig()
        SendNotification("Lunaris", "Saved Slot 2 position to disk.", 2)
    end
end, true)

createButtonRow(saveCard, "Teleport Location 2", "GOTO 2", "Teleports back to Slot 2 position", function()
    local root = getRootPart(LocalPlayer.Character)
    if root and Config.SaveSlot2 then
        root.CFrame = Config.SaveSlot2
        SendNotification("Lunaris", "Teleported to Slot 2.", 2)
    else
        SendNotification("Lunaris", "No location saved in Slot 2.", 2)
    end
end, true)

createCategoryHeader(tabFrames.Trolling, "Fling")
local flingCard = createCardGroup(tabFrames.Trolling)

local function flingCharacter(targetChar)
    if isFlinging then return end
    local char = LocalPlayer.Character
    local root = getRootPart(char)
    local tRoot = getRootPart(targetChar)
    if not root or not tRoot then return end

    local hum = getHumanoid(char)
    local tHum = getHumanoid(targetChar)
    if not hum or hum.Health <= 0 or not tHum or tHum.Health <= 0 then return end

    isFlinging = true
    local oldCF = root.CFrame

    if sethiddenproperty then
        pcall(sethiddenproperty, LocalPlayer, "SimulationRadius", 10000)
        pcall(sethiddenproperty, LocalPlayer, "MaxSimulationRadius", 10000)
    end
    if setsimulationradius then
        pcall(setsimulationradius, 10000)
    end

    for _, obj in ipairs(root:GetChildren()) do
        if obj:IsA("BodyMover") then
            pcall(function() obj:Destroy() end)
        end
    end

    local bAV = Instance.new("BodyAngularVelocity")
    bAV.Name = "FlingTorque"
    bAV.AngularVelocity = Vector3.new(0, 9e9, 0)
    bAV.MaxTorque = Vector3.new(0, 9e9, 0)
    bAV.P = 9e9
    bAV.Parent = root

    local bV = Instance.new("BodyVelocity")
    bV.Name = "FlingVelocity"
    bV.Velocity = Vector3.new(0, 0, 0)
    bV.MaxForce = Vector3.new(9e9, 9e9, 9e9)
    bV.Parent = root

    local steppedConn = RunService.Stepped:Connect(function()
        if not char or not root or not root.Parent then return end
        for _, child in ipairs(char:GetDescendants()) do
            if child:IsA("BasePart") then
                child.CanCollide = false
            end
        end
    end)

    local startTime = tick()
    local duration = 1.5

    while tick() - startTime < duration do
        if not targetChar or not targetChar.Parent or not tRoot or not tRoot.Parent or tHum.Health <= 0 then
            break
        end
        if not char or not char.Parent or not root or not root.Parent or hum.Health = 5 and s.playing <s>= 2 and s.playing <s> 0 then
                local chosen = validServers[math.random(1, #validServers)]
                SendNotification("Lunaris", "Teleporting (" .. chosen.playing .. "/" .. chosen.maxPlayers .. ")...", 3)
                task.wait(0.1)
                pcall(function()
                    TeleportService:TeleportToPlaceInstance(game.PlaceId, chosen.id, LocalPlayer)
                end)
                return
            end
        end
    end
    SendNotification("Lunaris", "No alternative servers found.", 2)
end, true)

createButtonRow(srvCard, "Server Hop (Low Player)", "LOW POP", "Joins a low player count server for farming", function()
    queueReinject()
    SendNotification("Lunaris", "Searching for low-pop server...", 2)
    local url = "https://games.roblox.com/v1/games/" .. tostring(game.PlaceId) .. "/servers/Public?sortOrder=Asc&limit=100"
    local ok, res = pcall(function() return game:HttpGet(url) end)
    if ok and res then
        local data = nil
        pcall(function() data = HttpService:JSONDecode(res) end)
        if data and data.data then
            local candidates = {}
            for _, s in ipairs(data.data) do
                if s.id ~= game.JobId and type(s.playing) == "number" and type(s.maxPlayers) == "number" and s.playing >= 2 and s.playing = 2 and s.playing <s> 0 then
                local chosen = candidates[1]
                SendNotification("Lunaris", "Joining low-pop (" .. chosen.playing .. "/" .. chosen.maxPlayers .. ")...", 3)
                task.wait(0.1)
                pcall(function()
                    TeleportService:TeleportToPlaceInstance(game.PlaceId, chosen.id, LocalPlayer)
                end)
                return
            end
        end
    end
    SendNotification("Lunaris", "No low-population servers found.", 2)
end, true)

createButtonRow(srvCard, "Unload Lunaris", "UNLOAD", "Closes UI and cleans all hooks & ESP", function()
    if getgenv().IdenticalMM2Unload then
        getgenv().IdenticalMM2Unload()
    end
end, true)

SyncUIWithConfig = function()
    isSyncingUI = true
    for key, c in pairs(ctrls) do
        if Config[key] ~= nil then
            if c.SetState then
                c.SetState(Config[key])
            elseif c.SetValue then
                c.SetValue(Config[key])
            elseif c.SetSelected then
                c.SetSelected(Config[key])
            end
        end
    end
    isSyncingUI = false
end

SyncUIWithConfig()

switchTab("Home")

searchBox:GetPropertyChangedSignal("Text"):Connect(function()
    local q = string.lower(searchBox.Text:gsub("^%s*(.-)%s*$", "%1"))
    for _, item in ipairs(rowSearchIndex) do
        item.frame.Visible = (q == "" or string.find(item.query, q, 1, true) ~= nil)
    end
end)

-- Toggle: hides/shows only the main window. The floating button stays visible.
local toggleToken = 0
ToggleUiVisibility = function()
    uiVisible = not uiVisible
    toggleToken = toggleToken + 1
    local token = toggleToken

    TweenService:Create(fcOuter, TweenInfo.new(0.2), {
        BackgroundColor3 = uiVisible and Colors.PurplePrimary or Colors.PurpleMuted
    }):Play()

    if uiVisible then
        mainScale.Scale = 0.92
        mainFrame.Visible = true
        TweenService:Create(mainScale, TweenInfo.new(0.18, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Scale = 1}):Play()
    else
        local tw = TweenService:Create(mainScale, TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {Scale = 0.92})
        tw:Play()
        tw.Completed:Connect(function()
            if token == toggleToken and not uiVisible then
                mainFrame.Visible = false
            end
        end)
    end
end

minBtn.MouseButton1Click:Connect(function()
    isMinimized = not isMinimized
    bodyFrame.Visible = not isMinimized
    footerBar.Visible = not isMinimized
    mainFrame.Size = isMinimized and UDim2.new(0, 660, 0, 46) or UDim2.new(0, 660, 0, 440)
    minBtn.Text = isMinimized and "+" or "-"
end)


closeBtn.MouseButton1Click:Connect(ToggleUiVisibility)

-- ===== Info / Contact panel (press P) =====
local TELEGRAM_LINK = "https://t.me/ix_ahmed_x"

local infoPanel = Instance.new("Frame")
infoPanel.Name = "InfoPanel"
infoPanel.Size = UDim2.new(0, 320, 0, 190)
infoPanel.Position = UDim2.new(0.5, -160, 0.5, -95)
infoPanel.BackgroundColor3 = Colors.Background
infoPanel.BorderSizePixel = 0
infoPanel.Visible = false
infoPanel.ZIndex = 2000
infoPanel.Parent = screenGui

local ipCorner = Instance.new("UICorner")
ipCorner.CornerRadius = UDim.new(0, 12)
ipCorner.Parent = infoPanel

local ipStroke = Instance.new("UIStroke")
ipStroke.Color = Color3.new(1, 1, 1)
ipStroke.Thickness = 1.5
ipStroke.Parent = infoPanel

local ipStrokeGrad = Instance.new("UIGradient")
ipStrokeGrad.Color = ColorSequence.new(Colors.PurpleAccent, Colors.PurpleGlow)
ipStrokeGrad.Rotation = 45
ipStrokeGrad.Parent = ipStroke

local ipScale = Instance.new("UIScale")
ipScale.Scale = 1
ipScale.Parent = infoPanel

local function ipLabel(text, font, size, color, yPos, height)
    local l = Instance.new("TextLabel")
    l.Size = UDim2.new(1, -24, 0, height)
    l.Position = UDim2.new(0, 12, 0, yPos)
    l.BackgroundTransparency = 1
    l.Font = font
    l.Text = text
    l.TextColor3 = color
    l.TextSize = size
    l.TextXAlignment = Enum.TextXAlignment.Center
    l.ZIndex = 2001
    l.Parent = infoPanel
    return l
end

ipLabel("LUNARIS", Enum.Font.GothamBold, 22, Colors.PurplePrimary, 14, 28)
ipLabel("Murder Mystery 2", Enum.Font.Gotham, 11, Colors.PurpleMuted, 40, 16)
ipLabel("By Ahmed Shawky", Enum.Font.GothamBold, 15, Colors.TextPrimary, 68, 22)
ipLabel("Telegram: t.me/ix_ahmed_x", Enum.Font.Gotham, 12, Colors.AccentBlue, 94, 18)

local function ipButton(text, xScale, xOffset, callback)
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0.5, -20, 0, 30)
    b.Position = UDim2.new(xScale, xOffset, 1, -46)
    b.BackgroundColor3 = Colors.PurpleDark
    b.BorderSizePixel = 0
    b.AutoButtonColor = false
    b.Font = Enum.Font.GothamBold
    b.Text = text
    b.TextColor3 = Colors.PurplePrimary
    b.TextSize = 12
    b.ZIndex = 2001
    b.Parent = infoPanel

    local c = Instance.new("UICorner")
    c.CornerRadius = UDim.new(0, 8)
    c.Parent = b

    local st = Instance.new("UIStroke")
    st.Color = Colors.PurpleAccent
    st.Thickness = 1
    st.Transparency = 0.5
    st.Parent = b

    b.MouseEnter:Connect(function()
        TweenService:Create(b, TweenInfo.new(0.12), {BackgroundColor3 = Colors.PurpleAccent, TextColor3 = Colors.Background}):Play()
    end)
    b.MouseLeave:Connect(function()
        TweenService:Create(b, TweenInfo.new(0.12), {BackgroundColor3 = Colors.PurpleDark, TextColor3 = Colors.PurplePrimary}):Play()
    end)
    b.MouseButton1Click:Connect(callback)
    return b
end

local infoVisible = false
local infoToken = 0
local function ToggleInfoPanel()
    infoVisible = not infoVisible
    infoToken = infoToken + 1
    local token = infoToken
    if infoVisible then
        ipScale.Scale = 0.9
        infoPanel.Visible = true
        TweenService:Create(ipScale, TweenInfo.new(0.18, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Scale = 1}):Play()
    else
        local tw = TweenService:Create(ipScale, TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {Scale = 0.9})
        tw:Play()
        tw.Completed:Connect(function()
            if token == infoToken and not infoVisible then
                infoPanel.Visible = false
            end
        end)
    end
end

ipButton("COPY LINK", 0, 14, function()
    if setclipboard then
        setclipboard(TELEGRAM_LINK)
        SendNotification("Lunaris", "Telegram link copied!", 2)
    else
        SendNotification("Lunaris", TELEGRAM_LINK, 4)
    end
end)
ipButton("CLOSE", 0.5, 6, function()
    if infoVisible then ToggleInfoPanel() end
end)
-- ===== End info panel =====

UserInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    if input.KeyCode == Enum.KeyCode.LeftControl then
        ToggleUiVisibility()
    elseif input.KeyCode == Enum.KeyCode.P then
        ToggleInfoPanel()
    elseif input.KeyCode == Enum.KeyCode.End then
        Config.KillAura = false
        Config.AutoShoot = false
        Config.CoinFarm = false
        Config.AutoKill = false
        SendNotification("Lunaris", "EMERGENCY STOP: Features halted.", 2)
    elseif input.KeyCode == Enum.KeyCode.Space and Config.InfiniteJump then
        local hum = getHumanoid(LocalPlayer.Character)
        if hum then hum:ChangeState(Enum.HumanoidStateType.Jumping) end
    end
end)

local function getOrCreateESP(id, adornee, text, color)
    local bb = trackedESPElements[id]
    if not bb or not bb.Parent then
        bb = Instance.new("BillboardGui")
        bb.Name = id
        bb.Size = UDim2.new(0, 140, 0, 40)
        bb.StudsOffset = Vector3.new(0, 2.5, 0)
        bb.AlwaysOnTop = true
        bb.MaxDistance = Config.ESPDistanceMax
        bb.Adornee = adornee
        bb.Parent = espFolder

        local tag = Instance.new("TextLabel")
        tag.Name = "Tag"
        tag.Size = UDim2.new(1, 0, 1, 0)
        tag.BackgroundTransparency = 1
        tag.Font = Enum.Font.GothamBold
        tag.TextSize = 11
        tag.TextColor3 = color
        tag.TextStrokeTransparency = 0.3
        tag.TextStrokeColor3 = Color3.new(0, 0, 0)
        tag.Parent = bb

        trackedESPElements[id] = bb
    end
    bb.Adornee = adornee
    bb.MaxDistance = Config.ESPDistanceMax
    local tag = bb:FindFirstChild("Tag")
    if tag then
        tag.Text = text
        tag.TextColor3 = color
    end
    return bb
end

local function getOrCreateCham(id, targetChar, color)
    local hl = trackedESPElements["cham_" .. id]
    if not hl or not hl.Parent then
        hl = Instance.new("Highlight")
        hl.Name = "cham_" .. id
        hl.FillColor = color
        hl.OutlineColor = Colors.TextPrimary
        hl.FillTransparency = 0.45
        hl.OutlineTransparency = 0.1
        hl.Adornee = targetChar
        hl.Parent = espFolder
        trackedESPElements["cham_" .. id] = hl
    end
    hl.Adornee = targetChar
    hl.FillColor = color
    return hl
end

local function updateTracer(id, targetPos, color)
    if not Drawing or not Drawing.new then return end
    local line = trackedTracers[id]
    if not line then
        pcall(function()
            line = Drawing.new("Line")
            line.Thickness = 1.5
            line.Transparency = 0.8
            line.Color = color
            trackedTracers[id] = line
        end)
        line = trackedTracers[id]
    end
    if not line then return end

    if Config.ESPTracers then
        local targetFeet = targetPos - Vector3.new(0, 2.5, 0)
        local screenPos, onScreen = Camera:WorldToViewportPoint(targetFeet)
        if onScreen then
            local localChar = LocalPlayer.Character
            local localRoot = getRootPart(localChar)
            local fromPos = nil

            if localRoot then
                local feetWorldPos = localRoot.Position - Vector3.new(0, 2.8, 0)
                local myScreenPos, myOnScreen = Camera:WorldToViewportPoint(feetWorldPos)
                if myOnScreen then
                    fromPos = Vector2.new(myScreenPos.X, myScreenPos.Y)
                end
            end

            if not fromPos then
                fromPos = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y)
            end

            line.From = fromPos
            line.To = Vector2.new(screenPos.X, screenPos.Y)
            line.Color = color
            line.Visible = true
        else
            line.Visible = false
        end
    else
        line.Visible = false
    end
end

local function removeTracer(id)
    if trackedTracers[id] then
        pcall(function() trackedTracers[id]:Remove() end)
        trackedTracers[id] = nil
    end
end

local function getClosestKnifeTarget()
    local char = LocalPlayer.Character
    local root = getRootPart(char)
    if not root then return nil end

    local mousePos = UserInputService:GetMouseLocation()
    local bestTarget = nil
    local bestDist = math.huge

    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer and isPlayerAlive(p) and p.Character then
            local tRoot = getRootPart(p.Character)
            if tRoot then
                local screenPos = Camera:WorldToViewportPoint(tRoot.Position)
                local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
                if (not Config.ShowFOV or dist <= Config.FOVRadius) and dist < bestDist then
                    bestDist = dist
                    bestTarget = p
                end
            end
        end
    end

    if not bestTarget then
        local minDist = math.huge
        for _, p in ipairs(Players:GetPlayers()) do
            if p ~= LocalPlayer and isPlayerAlive(p) and p.Character then
                local tRoot = getRootPart(p.Character)
                if tRoot then
                    local d = (root.Position - tRoot.Position).Magnitude
                    if d  0 and hum.FloorMaterial ~= Enum.Material.Air and velMag < 75 and angMag  120 or angMag > 90 then
                root.AssemblyLinearVelocity = Vector3.zero
                root.AssemblyAngularVelocity = Vector3.zero
                root.CFrame = lastSafePosition
            end

            if Config.AntiVoid and (lastSafePosition.Y - root.Position.Y > 30) then
                root.AssemblyLinearVelocity = Vector3.zero
                root.AssemblyAngularVelocity = Vector3.zero
                root.CFrame = lastSafePosition
            end
        end
    end

    if hum then
        if Config.SpeedEnabled then
            if hum.WalkSpeed ~= Config.SpeedValue then hum.WalkSpeed = Config.SpeedValue end
        else
            if hum.WalkSpeed ~= 16 and not Config.CoinFarm then hum.WalkSpeed = 16 end
        end

        if Config.JumpEnabled then
            if hum.JumpPower ~= Config.JumpValue then hum.JumpPower = Config.JumpValue end
        end
    end

    if Config.Noclip and char then
        for _, p in ipairs(char:GetDescendants()) do
            if p:IsA("BasePart") and p.CanCollide then
                p.CanCollide = false
            end
        end
    end

    if Config.Fullbright then
        Lighting.Ambient = Color3.new(1, 1, 1)
        Lighting.Brightness = 2
    end

    if Config.NoFog then
        Lighting.FogEnd = 1e6
    end

    local rtp = Workspace:FindFirstChild("RoundTimerPart")
    if rtp and rtp:FindFirstChild("SurfaceGui") then
        local sg = rtp.SurfaceGui
        local cr = sg:FindFirstChild("CurrentRound")
        local tm = sg:FindFirstChild("Timer")
        if cr and tm then
            statusRoundRow.SetValue(cr.Text)
            timerRoundRow.SetValue(tm.Text)
            if cr.Text == "Current Round" and not roundStartedFlag then
                roundStartedFlag = true
                if Config.AutoDrop then
                    local map = getActiveMap()
                    if map and root then
                        local p = map:FindFirstChild("Spawns") or map:FindFirstChildWhichIsA("BasePart")
                        if p then
                            local sp = p:IsA("Model") and p:GetChildren()[1] or p
                            if sp then root.CFrame = sp.CFrame * CFrame.new(0, 4, 0) end
                        end
                    end
                end
            elseif cr.Text ~= "Current Round" then
                roundStartedFlag = false
            end
        end
    end

    local murderer, sheriff = getRolePlayers()
    murdererRow.SetValue(murderer and (murderer.Name .. (isPlayerAlive(murderer) and "" or " [DEAD]")) or "Undetected")
    sheriffRow.SetValue(sheriff and (sheriff.Name .. (isPlayerAlive(sheriff) and "" or " [DEAD]")) or "Undetected")

    if Config.RoleESP and root then
        for _, p in ipairs(Players:GetPlayers()) do
            if p ~= LocalPlayer and p.Character and isPlayerAlive(p) then
                local pRoot = getRootPart(p.Character)
                if pRoot then
                    local dist = math.floor((root.Position - pRoot.Position).Magnitude)
                    if dist <= Config.ESPDistanceMax then
                        local role = getPlayerRole(p)
                        local col = Colors.AccentGreen
                        if role == "Murderer" then
                            col = Colors.AccentRed
                        elseif role == "Sheriff" then
                            col = Colors.AccentBlue
                        end

                        local text = p.Name
                        if Config.ESPNames then
                            text = "[" .. role .. "] " .. p.Name
                        end
                        if Config.ESPDistance then
                            text = text .. " (" .. dist .. "s)"
                        end

                        getOrCreateESP("mm2_" .. p.UserId, pRoot, text, col)
                        if Config.ESPChams then
                            getOrCreateCham(p.UserId, p.Character, col)
                        end
                        updateTracer("mm2_" .. p.UserId, pRoot.Position, col)
                    end
                end
            else
                if trackedESPElements["mm2_" .. p.UserId] then
                    trackedESPElements["mm2_" .. p.UserId]:Destroy()
                    trackedESPElements["mm2_" .. p.UserId] = nil
                end
                if trackedESPElements["cham_" .. p.UserId] then
                    trackedESPElements["cham_" .. p.UserId]:Destroy()
                    trackedESPElements["cham_" .. p.UserId] = nil
                end
                removeTracer("mm2_" .. p.UserId)
            end
        end
    end

    if Config.GunESP and root then
        local drop = getGunDrop()
        local gunPart = getGunDropPart(drop)
        if gunPart then
            local dist = math.floor((root.Position - gunPart.Position).Magnitude)
            if dist <= Config.ESPDistanceMax then
                getOrCreateESP("gun_drop", gunPart, "[GUN DROP] " .. dist .. "m", Colors.AccentYellow)
            end
        else
            clearESPCategory("gun_")
        end
    end

    if Config.CoinESP and root then
        local coins = getAllActiveCoins()
        for _, coin in ipairs(coins) do
            local dist = math.floor((root.Position - coin.Position).Magnitude)
            if dist <= Config.ESPDistanceMax then
                getOrCreateESP("coin_" .. coin:GetDebugId(), coin, "Coin", Colors.AccentYellow)
            end
        end
    end

    if Config.GrabGunAuto and root then
        local drop = getGunDrop()
        local gunPart = getGunDropPart(drop)
        if gunPart and (root.Position - gunPart.Position).Magnitude = 0.5) then
        local bp = LocalPlayer:FindFirstChild("Backpack")
        local gun = (bp and bp:FindFirstChild("Gun")) or (char and char:FindFirstChild("Gun"))
        if gun and murderer and murderer.Character and isPlayerAlive(murderer) then
            local mRoot = getRootPart(murderer.Character)
            if mRoot then
                if hum and bp and gun.Parent == bp then
                    hum:EquipTool(gun)
                end
                local rayAtt = root:FindFirstChild("GunRaycastAttachment")
                local origin = rayAtt and rayAtt.WorldCFrame or root.CFrame
                local aimPos = mRoot.Position
                if Config.AimPrediction then
                    aimPos = aimPos + (mRoot.AssemblyLinearVelocity * 0.12)
                end
                if gun:FindFirstChild("Shoot") then
                    gun.Shoot:FireServer(origin, CFrame.new(aimPos))
                    lastShootTick = now
                    if Config.SingleShot then Config.AutoShoot = false end
                end
            end
        end
    end

    if (Config.KillAura or Config.AutoKill) and root and (now - lastKnifeTick >= 0.2) then
        local bp = LocalPlayer:FindFirstChild("Backpack")
        local knife = (bp and bp:FindFirstChild("Knife")) or (char and char:FindFirstChild("Knife"))
        if knife then
            if hum and bp and knife.Parent == bp then
                hum:EquipTool(knife)
            end
            local events = knife:FindFirstChild("Events")
            if events then
                if Config.KillMode == "Throw" and events:FindFirstChild("KnifeThrown") and knife:FindFirstChild("Handle") then
                    local target = getClosestKnifeTarget()
                    if target and target.Character then
                        local tRoot = getRootPart(target.Character)
                        if tRoot then
                            local d = (root.Position - tRoot.Position).Magnitude
                            if Config.KillAll or d <= Config.AuraRange then
                                local targetPos = tRoot.Position
                                if Config.AimPrediction then
                                    local lead = Config.PingComp and 0.16 or 0.12
                                    targetPos = targetPos + (tRoot.AssemblyLinearVelocity * lead)
                                end
                                events.KnifeThrown:FireServer(knife.Handle.CFrame, CFrame.new(targetPos))
                                lastKnifeTick = now
                            end
                        end
                    end
                elseif events:FindFirstChild("HandleTouched") then
                    for _, p in ipairs(Players:GetPlayers()) do
                        if p ~= LocalPlayer and isPlayerAlive(p) then
                            local tRoot = getRootPart(p.Character)
                            if tRoot then
                                local d = (root.Position - tRoot.Position).Magnitude
                                if Config.KillAll or d <= Config.AuraRange then
                                    events.HandleTouched:FireServer(tRoot)
                                    if events:FindFirstChild("KnifeStabbed") then
                                        events.KnifeStabbed:FireServer()
                                    end
                                    lastKnifeTick = now
                                    if not Config.KillAll then
                                        break
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end

    if Config.HitboxExpander then
        for _, p in ipairs(Players:GetPlayers()) do
            if p ~= LocalPlayer and p.Character and isPlayerAlive(p) then
                local hrp = p.Character:FindFirstChild("HumanoidRootPart")
                if hrp then
                    if not originalHitboxSizes[hrp] then
                        originalHitboxSizes[hrp] = hrp.Size
                    end
                    hrp.Size = Vector3.new(Config.HitboxSize, Config.HitboxSize, Config.HitboxSize)
                    hrp.Transparency = Config.HitboxTransparency
                    hrp.CanCollide = false
                end
            end
        end
    end

    if Config.MurdererAvoid and root and murderer and murderer.Character and isPlayerAlive(murderer) then
        local mRoot = getRootPart(murderer.Character)
        if mRoot then
            local dist = (root.Position - mRoot.Position).Magnitude
            if dist = 0.05) then
        if Config.BagFullStop and getCurrentCoinCount() >= Config.CoinBagCap then
            Config.CoinFarm = false
            SendNotification("Lunaris", "Coin bag limit reached! Farming stopped.", 3)
        else
            local coins = getAllActiveCoins()
            local bestCoin = nil
            local bestDist = 1000

            for _, c in ipairs(coins) do
                local d = (root.Position - c.Position).Magnitude
                local isSafe = true
                if Config.SafeCoinFarm and murderer and murderer.Character and isPlayerAlive(murderer) then
                    local mRoot = getRootPart(murderer.Character)
                    if mRoot and (c.Position - mRoot.Position).Magnitude < Config.SafetyRadius then
                        isSafe = false
                    end
                end
                if isSafe and d < bestDist then
                    bestDist = d
                    bestCoin = c
                end
            end

            if bestCoin then
                if hum then
                    hum.WalkSpeed = Config.FarmSpeed
                end
                local targetPos = bestCoin.Position
                local dist = (root.Position - targetPos).Magnitude

                for _, part in ipairs(char:GetChildren()) do
                    if part:IsA("BasePart") then
                        part.CanCollide = false
                    end
                end

                local speed = Config.QuickFarm and 38 or math.clamp(Config.FarmSpeed, 16, 42)

                if Config.FarmMethod == "Tween" then
                    local travelTime = math.max(dist / speed, 0.05)
                    local tweenInfo = TweenInfo.new(travelTime, Enum.EasingStyle.Linear)
                    local tw = TweenService:Create(root, tweenInfo, {CFrame = CFrame.new(targetPos)})
                    tw:Play()
                    if dist  0.3 then
                        root.AssemblyLinearVelocity = dir.Unit * speed
                    else
                        root.AssemblyLinearVelocity = Vector3.zero
                    end
                    if dist  root.Position.Y + 2.0 and hum:GetState() ~= Enum.HumanoidStateType.Jumping then
                            hum:ChangeState(Enum.HumanoidStateType.Jumping)
                        end
                    end
                    if dist < 7 then
                        fireTouch(root, bestCoin)
                        local rHand = char:FindFirstChild("RightHand") or char:FindFirstChild("Right Arm")
                        if rHand then fireTouch(rHand, bestCoin) end
                    end
                end
                lastFarmTick = now
            end
        end
    end
end))

for _, p in ipairs(Players:GetPlayers()) do
    if p ~= LocalPlayer then
        p.CharacterAdded:Connect(function(c)
            local h = c:WaitForChild("Humanoid", 5)
            if h then
                h.Died:Connect(function()
                    table.insert(deadPlayersList, p.Name)
                    if Config.DeathNotifs then
                        local r = getPlayerRole(p)
                        SendNotification("Death Alert", p.Name .. " [" .. r .. "] has died!", 3)
                    end
                end)
            end
        end)
    end
end

Players.PlayerAdded:Connect(function(p)
    p.CharacterAdded:Connect(function(c)
        local h = c:WaitForChild("Humanoid", 5)
        if h then
            h.Died:Connect(function()
                table.insert(deadPlayersList, p.Name)
                if Config.DeathNotifs then
                    local r = getPlayerRole(p)
                    SendNotification("Death Alert", p.Name .. " [" .. r .. "] has died!", 3)
                end
            end)
        end
    end)
end)

LocalPlayer.Idled:Connect(function()
    if Config.AntiAFK then
        local VirtualUser = game:GetService("VirtualUser")
        VirtualUser:CaptureController()
        VirtualUser:ClickButton2(Vector2.new(0, 0))
    end
end)

getgenv().IdenticalMM2Unload = function()
    for _, conn in ipairs(activeConnections) do
        pcall(function() conn:Disconnect() end)
    end
    clearESPCategory("")
    for id in pairs(trackedTracers) do
        pcall(function() trackedTracers[id]:Remove() end)
    end
    if auraRingPart then
        auraRingPart:Destroy()
        auraRingPart = nil
    end
    if fovCircle then
        pcall(function() fovCircle:Remove() end)
        fovCircle = nil
    end
    for part, sz in pairs(originalHitboxSizes) do
        if part and part.Parent then
            part.Size = sz
            part.Transparency = 1
        end
    end
    if screenGui then screenGui:Destroy() end
    getgenv().IdenticalMM2Unload = nil
end

SendNotification("Lunaris", "By Ahmed Shawky", 5)
task.delay(0.4, function()
    SendNotification("Lunaris", "Loaded! Left-CTRL / crescent = menu, P = info.", 4)
end)
🎮 Similar Scripts
💬 Comments (0)
Login to post a comment
No comments yet. Be the first!
Script Info
Game Murder Mystery 2
TypeKeyless
Authorknockoutscripts
Views5
Likes0
PublishedDec 3, 2026
🎮 Play Game on Roblox
🕐 Recent Scripts
Azzy’s Evade Script keyless
Azzy’s Evade Script keyless
Evade • 👁 1
Keyless
Azure Latch script keyless | Celeron’s GUI
Azure Latch script keyless | Celeron’s GUI
Azure Latch • 👁 3
Keyless
Baddies Scam Trade Script
Baddies Scam Trade Script
Baddies 💅 • 👁 4
Keyless
Throw Food For Animals keyless script | Project Realm
Throw Food For Animals keyless script | Project Realm
Throw Food For Animals • 👁 5
Keyless
Huss Valley keyless script | Reef Hub
Huss Valley keyless script | Reef Hub
Huss Valley • 👁 5
Keyless