local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local RunService = game:GetService("RunService")
local VirtualUser = game:GetService("VirtualUser")
local StarterGui = game:GetService("StarterGui")
local CoreGui = game:GetService("CoreGui")
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = Players.LocalPlayer

local COMMAND_SENDER = "Teebiu"
local INSTANCE_PREFIX = "Teebiu"
local BOT_PREFIX = "Teebiu"

-- Names to completely ignore from flinging
local EXCLUDED_NAMES = {
    ["solsrngglobal235"] = true,
    ["teebiu"] = true,
    ["ryguyz14"] = true,
    ["raisin_helper"] = true,
    ["kupcake"] = true,
    ["egorsassistant"] = true,
}

local moderators = {}
local whitelistedUsers = {}
local controlsLocked = false
local antiFreezeEnabled = true
local antiIdleEnabled = true
local optimizedMode = false

local ORBIT_RADIUS = 8
local ORBIT_SPEED = 1
local LINE_SPACING = 4
local FOLLOW_DISTANCE = 2.2
local WALL_SPACING = 3.5

local SWAY_DISTANCE = 1.1
local SWAY_SPEED = 5
local BODY_SWAY_ANGLE = math.rad(8)
local ARM_FORWARD_ANGLE = math.rad(55)
local ARM_SIDE_ANGLE = math.rad(12)

local orbiting = false
local liningUp = false
local stacking = false
local congaing = false
local walling = false
local flinging = false
local spamFlinging = false

local target = nil
local originalCFrame = nil
local orbitStartTime = 0
local congaStartTime = 0

local autoDonating = false
local autoDonateTarget = ""
local autoDonateGoal = 0

local stuckTime = 0
local lastValidCFrame = nil

local function safeSendChat(messageText)
    pcall(function()
        local textChannels = TextChatService:FindFirstChild("TextChannels")
        if textChannels then
            local generalChannel = textChannels:FindFirstChild("RBXGeneral")
            if generalChannel then
                generalChannel:SendAsync(messageText)
                return
            end
        end
        if TextChatService:FindFirstChild("ChatInputBarConfiguration") then
            local targetChannel = TextChatService.ChatInputBarConfiguration.TargetTextChannel
            if targetChannel then
                targetChannel:SendAsync(messageText)
            end
        end
    end)
end

local function isCommander(player)
    return player and player.Name:lower() == COMMAND_SENDER:lower()
end

local function isTeebiuInstance(player)
    if not player then return false end
    local name = player.Name:lower()
    local prefix = INSTANCE_PREFIX:lower()
    return name:sub(1, #prefix) == prefix
end

local function isModerator(player)
    if not player then return false end
    if isCommander(player) then return true end
    return moderators[player.Name:lower()] == true
end

local function isWhitelisted(player)
    if not player then return false end
    if isModerator(player) then return true end
    return whitelistedUsers[player.Name:lower()] == true
end

local function isIgnoredForFling(player)
    if not player then return true end
    local nameLower = player.Name:lower()
    if EXCLUDED_NAMES[nameLower] then return true end
    if isCommander(player) then return true end
    if isTeebiuInstance(player) then return true end
    return false
end

local function sendNotification(title, text)
    pcall(function()
        StarterGui:SetCore("SendNotification", {
            Title = title,
            Text = text,
            Duration = 5,
        })
    end)
end

sendNotification("TeeWare", "Made by: Teebiu and IlIChezee_1, Credits to: solsrngglobal235")

task.spawn(function()
    task.wait(1.5)
    if not isCommander(LocalPlayer) and LocalPlayer.Name:find(BOT_PREFIX) then
        safeSendChat("Made by: Teebiu and IlIChezee_1, Credits to: solsrngglobal235")
    end
end)

local function findPlayer(text)
    if not text or text == "" then return nil end
    text = string.lower(text)
    for _, player in ipairs(Players:GetPlayers()) do
        if string.lower(player.Name) == text then
            return player
        end
    end
    for _, player in ipairs(Players:GetPlayers()) do
        if string.sub(string.lower(player.Name), 1, #text) == text then
            return player
        end
    end
    return nil
end

local function getInstanceNumber(player)
    if not player then return math.huge end
    local number = string.match(player.Name, "^Teebiu_(%d+)$") or string.match(player.Name, "^Teebiu(%d*)$")
    return tonumber(number) or math.huge
end

local function getParticipants()
    local participants = {}
    for _, player in ipairs(Players:GetPlayers()) do
        if isTeebiuInstance(player) and not isCommander(player) then
            table.insert(participants, player)
        end
    end
    table.sort(participants, function(a, b)
        return getInstanceNumber(a) < getInstanceNumber(b)
    end)
    return participants
end

local function getPlayerAhead()
    local participants = getParticipants()
    if #participants == 0 then return nil end
    for index, player in ipairs(participants) do
        if player == LocalPlayer then
            if index > 1 then
                return participants[index - 1]
            end
            return target
        end
    end
    return nil
end

local function getMySlot()
    if not target or not target.Parent then return nil end
    local participants = getParticipants()
    for index, player in ipairs(participants) do
        if player == LocalPlayer then
            return index, #participants
        end
    end
    return nil
end

local function getRoot(player)
    if not player then return nil end
    local character = player.Character
    if not character then return nil end
    return character:FindFirstChild("HumanoidRootPart")
end

local function setArmPose(character, sway)
    if not character then return end
    local upperTorso = character:FindFirstChild("UpperTorso")
    if upperTorso then
        local leftShoulder = upperTorso:FindFirstChild("LeftShoulder")
        local rightShoulder = upperTorso:FindFirstChild("RightShoulder")
        if leftShoulder then leftShoulder.Transform = CFrame.Angles(-ARM_FORWARD_ANGLE, -ARM_SIDE_ANGLE + sway, 0) end
        if rightShoulder then rightShoulder.Transform = CFrame.Angles(-ARM_FORWARD_ANGLE, ARM_SIDE_ANGLE + sway, 0) end
        return
    end
    local torso = character:FindFirstChild("Torso")
    if torso then
        local leftShoulder = torso:FindFirstChild("Left Shoulder")
        local rightShoulder = torso:FindFirstChild("Right Shoulder")
        if leftShoulder then leftShoulder.Transform = CFrame.Angles(-ARM_FORWARD_ANGLE, -ARM_SIDE_ANGLE + sway, 0) end
        if rightShoulder then rightShoulder.Transform = CFrame.Angles(-ARM_FORWARD_ANGLE, ARM_SIDE_ANGLE + sway, 0) end
    end
end

local function resetArmPose(character)
    if not character then return end
    local upperTorso = character:FindFirstChild("UpperTorso")
    if upperTorso then
        local leftShoulder = upperTorso:FindFirstChild("LeftShoulder")
        local rightShoulder = upperTorso:FindFirstChild("RightShoulder")
        if leftShoulder then leftShoulder.Transform = CFrame.identity end
        if rightShoulder then rightShoulder.Transform = CFrame.identity end
        return
    end
    local torso = character:FindFirstChild("Torso")
    if torso then
        local leftShoulder = torso:FindFirstChild("Left Shoulder")
        local rightShoulder = torso:FindFirstChild("Right Shoulder")
        if leftShoulder then leftShoulder.Transform = CFrame.identity end
        if rightShoulder then rightShoulder.Transform = CFrame.identity end
    end
end

local function updateFormations()
    if isCommander(LocalPlayer) then return end
    if flinging or spamFlinging then return end
    if not target or not target.Parent then
        orbiting = false
        liningUp = false
        stacking = false
        congaing = false
        walling = false
        return
    end
    local targetCharacter = target.Character
    local myCharacter = LocalPlayer.Character
    if not targetCharacter or not myCharacter then return end
    local targetRoot = targetCharacter:FindFirstChild("HumanoidRootPart")
    local myRoot = myCharacter:FindFirstChild("HumanoidRootPart")
    if not targetRoot or not myRoot then return end

    if orbiting then
        local index, count = getMySlot()
        if not index or count <= 0 then return end
        local angleOffset = ((index - 1) / count) * math.pi * 2
        local elapsedTime = os.clock() - (orbitStartTime or os.clock())
        local angle = angleOffset + (elapsedTime * ORBIT_SPEED)
        local right = targetRoot.CFrame.RightVector
        local forward = targetRoot.CFrame.LookVector
        local offset = right * math.cos(angle) * ORBIT_RADIUS + forward * math.sin(angle) * ORBIT_RADIUS
        local position = targetRoot.Position + offset
        
        pcall(function()
            myRoot.CFrame = CFrame.lookAt(position, targetRoot.Position)
        end)
    elseif liningUp then
        local index, count = getMySlot()
        if not index or count <= 0 then return end
        local lookVector = targetRoot.CFrame.LookVector
        local position = targetRoot.Position - (lookVector * (index * LINE_SPACING))
        
        pcall(function()
            myRoot.CFrame = CFrame.lookAt(position, targetRoot.Position)
        end)
    elseif stacking then
        pcall(function()
            myRoot.CFrame = targetRoot.CFrame
        end)
    elseif walling then
        local participants = getParticipants()
        local index = nil
        for i, p in ipairs(participants) do
            if p == LocalPlayer then
                index = i
                break
            end
        end
        if not index then return end
        
        local totalBots = #participants
        local centerOffset = (totalBots - 1) / 2
        local relativeIndex = (index - 1) - centerOffset
        
        local rightVector = targetRoot.CFrame.RightVector
        local lookVector = targetRoot.CFrame.LookVector
        local position = targetRoot.Position + (lookVector * 3) + (rightVector * (relativeIndex * WALL_SPACING))
        
        pcall(function()
            myRoot.CFrame = CFrame.lookAt(position, position + lookVector)
        end)
    elseif congaing then
        local ahead = getPlayerAhead()
        if not ahead then return end
        local aheadRoot = getRoot(ahead)
        if not aheadRoot then return end
        local elapsed = os.clock() - congaStartTime
        local instanceNumber = getInstanceNumber(LocalPlayer)
        local phase = elapsed * SWAY_SPEED - instanceNumber * 0.35
        local sway = math.sin(phase) * SWAY_DISTANCE
        local bodySway = math.sin(phase) * BODY_SWAY_ANGLE
        local behindPosition = aheadRoot.Position - aheadRoot.CFrame.LookVector * FOLLOW_DISTANCE
        local swayPosition = behindPosition + aheadRoot.CFrame.RightVector * sway
        pcall(function()
            myRoot.CFrame = CFrame.new(swayPosition, swayPosition + aheadRoot.CFrame.LookVector) * CFrame.Angles(0, bodySway, 0)
        end)
        setArmPose(myCharacter, math.sin(phase + math.pi / 2) * ARM_SIDE_ANGLE)
    end
end

local function clearFormations()
    if isCommander(LocalPlayer) then return end
    local wasActive = orbiting or liningUp or stacking or congaing or walling or flinging or spamFlinging
    orbiting = false
    liningUp = false
    stacking = false
    congaing = false
    walling = false
    flinging = false
    spamFlinging = false
    local oldTarget = target
    target = nil
    local character = LocalPlayer.Character
    if character then
        resetArmPose(character)
        local root = character:FindFirstChild("HumanoidRootPart")
        if root and originalCFrame then
            pcall(function()
                root.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
                root.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
                root.CFrame = originalCFrame
            end)
        end
    end
    originalCFrame = nil
    if oldTarget and wasActive then
        safeSendChat("stopped")
    end
end

-- Shared Unlimited Sweeping Fling Routine
local function executeFlingLoop(isContinuous)
    if isCommander(LocalPlayer) then return end
    if flinging or spamFlinging then return end
    
    if isContinuous then
        spamFlinging = true
    else
        flinging = true
    end

    task.spawn(function()
        local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
        local rootPart = character:WaitForChild("HumanoidRootPart")
        
        originalCFrame = rootPart.CFrame

        while (isContinuous and spamFlinging) or (not isContinuous and flinging) do
            local targets = {}
            for _, player in ipairs(Players:GetPlayers()) do
                if not isIgnoredForFling(player) and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
                    local tRoot = player.Character.HumanoidRootPart
                    if tRoot.AssemblyLinearVelocity.Magnitude <= 35 then
                        table.insert(targets, player)
                    end
                end
            end

            if #targets == 0 then
                if not isContinuous then break end
                task.wait(1)
            else
                -- Shuffle targets randomly
                for i = #targets, 2, -1 do
                    local j = math.random(i)
                    targets[i], targets[j] = targets[j], targets[i]
                end

                for _, targetPlayer in ipairs(targets) do
                    if (isContinuous and not spamFlinging) or (not isContinuous and not flinging) then break end
                    if targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
                        local targetRoot = targetPlayer.Character.HumanoidRootPart
                        if targetRoot.AssemblyLinearVelocity.Magnitude <= 40 then
                            target = targetPlayer

                            -- Turn off collisions
                            for _, part in ipairs(character:GetDescendants()) do
                                if part:IsA("BasePart") then part.CanCollide = false end
                            end

                            local initialTargetPos = targetRoot.Position
                            local tickCount = 0

                            while (isContinuous and spamFlinging) or (not isContinuous and flinging) do
                                if not targetPlayer.Character or not targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
                                    break
                                end
                                if targetPlayer.Character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude > 70 then
                                    break
                                end

                                tickCount = tickCount + 1
                                local offsetVal = math.sin(tickCount * 2) * 2
                                local targetCF = targetPlayer.Character.HumanoidRootPart.CFrame

                                rootPart.CFrame = targetCF * CFrame.new(0, 0, offsetVal)
                                rootPart.AssemblyLinearVelocity = Vector3.new(5000, 5000, 5000)

                                local currentDist = (targetPlayer.Character.HumanoidRootPart.Position - initialTargetPos).Magnitude
                                if currentDist > 15 then
                                    break
                                end

                                task.wait(0.05)
                            end

                            rootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
                            task.wait(0.2)
                        end
                    end
                end
            end

            if not isContinuous then break end
            task.wait(0.5)
        end

        -- Clean up & Return home
        flinging = false
        if not spamFlinging then
            rootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
            rootPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
            if originalCFrame then
                rootPart.CFrame = originalCFrame
            end
            originalCFrame = nil
            target = nil
        end
    end)
end

local function processCommand(text, sender)
    pcall(function()
        local allowed = isWhitelisted(sender)
        if not allowed then return end
        if controlsLocked and not isCommander(sender) then return end
        
        if text:sub(1, 1) == "!" then
            text = text:sub(2)
        else
            return
        end

        local lowerText = text:lower()

        if lowerText:match("^antifreeze%s*$") then
            if not isModerator(sender) then return end
            if not isCommander(LocalPlayer) then
                safeSendChat("antifreeze")
            end
            return
        end

        if lowerText:match("^optimize%s*$") or lowerText:match("^opt%s*$") then
            if isCommander(sender) then
                optimizedMode = not optimizedMode
                if not isCommander(LocalPlayer) then
                    pcall(function()
                        if setfpscap then setfpscap(optimizedMode and 15 or 60) end
                        if RunService.Set3dRenderingEnabled then
                            RunService:Set3dRenderingEnabled(not optimizedMode)
                        end
                    end)
                    safeSendChat("optimized")
                end
            end
            return
        end

        if lowerText:match("^antiidle%s*$") then
            if isCommander(sender) then
                antiIdleEnabled = not antiIdleEnabled
                if not isCommander(LocalPlayer) then
                    safeSendChat("anti-idle")
                end
            end
            return
        end

        if lowerText:match("^lock%s*$") then
            if isCommander(sender) then
                controlsLocked = true
                if not isCommander(LocalPlayer) then safeSendChat("locked") end
            end
            return
        end
        if lowerText:match("^unlock%s*$") then
            if isCommander(sender) then
                controlsLocked = false
                if not isCommander(LocalPlayer) then safeSendChat("unlocked") end
            end
            return
        end

        if lowerText:match("^outward%s*$") then
            faceOutward = true
            if not isCommander(LocalPlayer) then safeSendChat("outward") end
            return
        end

        local speedVal = text:match("^orbitspeed%s+(.-)%s*$")
        if speedVal then
            local num = tonumber(speedVal)
            if num then
                ORBIT_SPEED = num
                if not isCommander(LocalPlayer) then safeSendChat("speed " .. tostring(ORBIT_SPEED)) end
            end
            return
        end

        local sizeVal = text:match("^orbitsize%s+(.-)%s*$")
        if sizeVal then
            local num = tonumber(sizeVal)
            if num then
                ORBIT_RADIUS = num
                if not isCommander(LocalPlayer) then safeSendChat("size " .. tostring(ORBIT_RADIUS)) end
            end
            return
        end

        if lowerText:match("^copy%s*$") then
            if isCommander(sender) then
                copyingChat = true
                if not isCommander(LocalPlayer) then safeSendChat("copying") end
            end
            return
        end
        if lowerText:match("^uncopy%s*$") then
            if isCommander(sender) then
                copyingChat = false
                if not isCommander(LocalPlayer) then safeSendChat("uncopied") end
            end
            return
        end

        local modTargetName = text:match("^mod%s+(.-)%s*$")
        if modTargetName then
            if isCommander(sender) then
                local targetPlayer = findPlayer(modTargetName)
                if targetPlayer then
                    moderators[targetPlayer.Name:lower()] = true
                    if not isCommander(LocalPlayer) then safeSendChat("mod " .. targetPlayer.Name) end
                end
            end
            return
        end
        local unmodTargetName = text:match("^unmod%s+(.-)%s*$")
        if unmodTargetName then
            if isCommander(sender) then
                local targetPlayer = findPlayer(unmodTargetName)
                if targetPlayer then
                    moderators[targetPlayer.Name:lower()] = nil
                    if not isCommander(LocalPlayer) then safeSendChat("unmod " .. targetPlayer.Name) end
                end
            end
            return
        end

        local whitelistTargetName = text:match("^whitelist%s+(.-)%s*$")
        if whitelistTargetName then
            if isCommander(sender) then
                local targetPlayer = findPlayer(whitelistTargetName)
                if targetPlayer then
                    whitelistedUsers[targetPlayer.Name:lower()] = true
                    if not isCommander(LocalPlayer) then safeSendChat("wl " .. targetPlayer.Name) end
                end
            end
            return
        end
        local unwhitelistTargetName = text:match("^unwhitelist%s+(.-)%s*$")
        if unwhitelistTargetName then
            if isCommander(sender) then
                local targetPlayer = findPlayer(unwhitelistTargetName)
                if targetPlayer then
                    whitelistedUsers[targetPlayer.Name:lower()] = nil
                    if not isCommander(LocalPlayer) then safeSendChat("unwl " .. targetPlayer.Name) end
                end
            end
            return
        end

        if lowerText:match("^mods%s*$") then
            if not isCommander(LocalPlayer) then
                safeSendChat("mods")
            end
            return
        end

        if lowerText:match("^whitelists%s*$") or lowerText:match("^wlist%s*$") then
            if not isCommander(LocalPlayer) then
                safeSendChat("whitelisted")
            end
            return
        end

        local sayMessage = text:match('^say%s+"(.-)"%s*$') or text:match("^say%s+(.-)%s*$")
        if sayMessage then
            if not isCommander(LocalPlayer) and LocalPlayer.Name:find(BOT_PREFIX) then
                safeSendChat(sayMessage)
            end
            return
        end

        if lowerText:match("^commands%s*$") then
            if not isCommander(LocalPlayer) and LocalPlayer.Name:find(BOT_PREFIX) then
                if isCommander(sender) then
                    safeSendChat("Commands part 1: orbit, line, stack, formwall, conga, fling, spamfling, unorbit, outward, orbitspeed, orbitsize, copy, uncopy, lock, unlock")
                    task.wait(0.6)
                    safeSendChat("Commands part 2: mod, unmod, whitelist, unwhitelist, optimize, antiidle, bring, re, dono, autodonate, unautodonate, say, commands")
                elseif isModerator(sender) then
                    safeSendChat("Mod commands: orbit, line, stack, formwall, conga, fling, spamfling, unorbit, outward, antifreeze, dono, autodonate, unautodonate, say, commands")
                else
                    safeSendChat("Commands: orbit, line, stack, formwall, conga, fling, spamfling, unorbit, outward, say, commands")
                end
            end
            return
        end

        local donoTargetName = text:match("^dono%s*(.-)%s*$")
        if donoTargetName ~= nil then
            if not isModerator(sender) then return end
            if donoTargetName == "" then donoTargetName = "Teebiu" end
            if not isCommander(LocalPlayer) and LocalPlayer.Name:find(BOT_PREFIX) then
                local leaderstats = LocalPlayer:FindFirstChild("leaderstats")
                local timeStat = nil
                if leaderstats then
                    timeStat = leaderstats:FindFirstChild("Time") 
                        or leaderstats:FindFirstChild("PlayTime") 
                        or leaderstats:FindFirstChild("OnlineTime")
                end
                local timeValue = timeStat and timeStat.Value or 100
                safeSendChat("Donate " .. donoTargetName .. " " .. tostring(timeValue))
            end
            return
        end

        local autoUser, autoAmount = text:match("^autodonate%s+(%S+)%s+(%S+)%s*$")
        if autoUser then
            if not isModerator(sender) then return end
            autoDonateTarget = autoUser
            autoDonateGoal = tonumber(autoAmount) or 0
            autoDonating = true
            if not isCommander(LocalPlayer) and LocalPlayer.Name:find(BOT_PREFIX) then
                safeSendChat("auto dono " .. autoDonateTarget)
            end
            return
        end

        if lowerText:match("^unautodonate%s*$") then
            if not isModerator(sender) then return end
            autoDonating = false
            if not isCommander(LocalPlayer) then
                safeSendChat("dono off")
            end
            return
        end

        local bringUsername = text:match("^bring%s*(.-)%s*$")
        if bringUsername ~= nil then
            if isCommander(sender) and not isCommander(LocalPlayer) then
                local char = LocalPlayer.Character
                local root = char and char:FindFirstChild("HumanoidRootPart")
                local targetPlayer = (bringUsername == "") and sender or findPlayer(bringUsername)
                local targetChar = targetPlayer and targetPlayer.Character
                local targetRoot = targetChar and targetChar:FindFirstChild("HumanoidRootPart")
                if root and targetRoot then
                    root.CFrame = targetRoot.CFrame + Vector3.new(0, 3, 0)
                end
            end
            return
        end
        if lowerText:match("^re%s*$") or lowerText:match("^respawn%s*$") then
            if isCommander(sender) and not isCommander(LocalPlayer) then
                local char = LocalPlayer.Character
                local humanoid = char and char:FindFirstChildOfClass("Humanoid")
                if humanoid then humanoid.Health = 0 end
            end
            return
        end

        if lowerText:match("^unorbit%s*$") or lowerText:match("^unconga%s*$") or lowerText:match("^unfling%s*$") or lowerText:match("^unspamfling%s*$") then
            clearFormations()
            if not isCommander(LocalPlayer) then safeSendChat("stopped") end
            return
        end

        if lowerText:match("^fling%s*$") then
            if not isCommander(LocalPlayer) then
                safeSendChat("flinging server")
                executeFlingLoop(false)
            end
            return
        end

        if lowerText:match("^spamfling%s*$") then
            if not isCommander(LocalPlayer) then
                safeSendChat("spam flinging server")
                executeFlingLoop(true)
            end
            return
        end

        if not isCommander(LocalPlayer) then
            local character = LocalPlayer.Character
            if character then
                local root = character:FindFirstChild("HumanoidRootPart")
                if root and not (orbiting or liningUp or stacking or congaing or walling or flinging or spamFlinging) then
                    originalCFrame = root.CFrame
                end
            end
        end

        local lineUsername = text:match("^line%s*(.-)%s*$")
        if lineUsername ~= nil then
            orbiting, liningUp, stacking, congaing, walling, flinging, spamFlinging, faceOutward = false, true, false, false, false, false, false, false
            orbitStartTime = os.clock()
            target = (lineUsername == "") and sender or findPlayer(lineUsername)
            if not target then return end
            if not isCommander(LocalPlayer) then safeSendChat("in line behind " .. target.Name .. ". No cutting in line son😂") end
            updateFormations()
            return
        end

        local stackUsername = text:match("^stack%s*(.-)%s*$")
        if stackUsername ~= nil then
            orbiting, liningUp, stacking, congaing, walling, flinging, spamFlinging, faceOutward = false, false, true, false, false, false, false, false
            orbitStartTime = os.clock()
            target = (stackUsername == "") and sender or findPlayer(stackUsername)
            if not target then return end
            if not isCommander(LocalPlayer) then safeSendChat("stacking " .. target.Name) end
            updateFormations()
            return
        end

        local wallUsername = text:match("^formwall%s*(.-)%s*$")
        if wallUsername ~= nil then
            orbiting, liningUp, stacking, congaing, walling, flinging, spamFlinging, faceOutward = false, false, false, false, true, false, false, false
            orbitStartTime = os.clock()
            target = (wallUsername == "") and sender or findPlayer(wallUsername)
            if not target then return end
            if not isCommander(LocalPlayer) then safeSendChat("walling " .. target.Name) end
            updateFormations()
            return
        end

        local congaUsername = text:match("^conga%s*(.-)%s*$")
        if congaUsername ~= nil then
            orbiting, liningUp, stacking, congaing, walling, flinging, spamFlinging, faceOutward = false, false, false, true, false, false, false, false
            congaStartTime = os.clock()
            target = (congaUsername == "") and sender or findPlayer(congaUsername)
            if not target then return end
            if not isCommander(LocalPlayer) then safeSendChat("conga " .. target.Name) end
            updateFormations()
            return
        end

        local orbitUsername = text:match("^orbit%s*(.-)%s*$")
        if orbitUsername ~= nil then
            orbiting, liningUp, stacking, congaing, walling, flinging, spamFlinging = true, false, false, false, false, false, false
            orbitStartTime = os.clock()
            target = (orbitUsername == "") and sender or findPlayer(orbitUsername)
            if not target then return end
            if not isCommander(LocalPlayer) then safeSendChat("orbiting " .. target.Name) end
            updateFormations()
            return
        end
    end)
end

TextChatService.MessageReceived:Connect(function(message)
    pcall(function()
        local source = message.TextSource
        if not source then return end
        local sender = Players:GetPlayerByUserId(source.UserId)
        if not sender then return end

        processCommand(message.Text, sender)

        if copyingChat and isCommander(sender) and not isCommander(LocalPlayer) then
            if not message.Text:match("^!") then
                task.wait(math.random(0.1, 0.3))
                safeSendChat(message.Text)
            end
        end
    end)
end)

task.spawn(function()
    pcall(function()
        local screenGui = Instance.new("ScreenGui")
        screenGui.Name = "TeeWareSilentUI"
        screenGui.ResetOnSpawn = false
        screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
        
        local toggleButton = Instance.new("TextButton")
        toggleButton.Name = "ToggleCmdButton"
        toggleButton.Size = UDim2.new(0, 110, 0, 28)
        toggleButton.Position = UDim2.new(0.5, -55, 0, 5)
        toggleButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
        toggleButton.BorderColor3 = Color3.fromRGB(100, 100, 100)
        toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
        toggleButton.Text = "[ ; ] TeeWare"
        toggleButton.TextSize = 12
        toggleButton.Font = Enum.Font.SourceSansBold
        toggleButton.Parent = screenGui
        
        local btnCorner = Instance.new("UICorner")
        btnCorner.CornerRadius = UDim.new(0, 5)
        btnCorner.Parent = toggleButton

        local textBox = Instance.new("TextBox")
        textBox.Name = "CommandInput"
        textBox.Size = UDim2.new(0, 280, 0, 34)
        textBox.Position = UDim2.new(0.5, -140, 0, 38)
        textBox.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
        textBox.BorderColor3 = Color3.fromRGB(80, 80, 80)
        textBox.TextColor3 = Color3.fromRGB(255, 255, 255)
        textBox.PlaceholderText = "Type command here..."
        textBox.Text = ""
        textBox.TextSize = 14
        textBox.Font = Enum.Font.SourceSansBold
        textBox.ClearTextOnFocus = false
        textBox.Visible = false
        textBox.Parent = screenGui
        
        local corner = Instance.new("UICorner")
        corner.CornerRadius = UDim.new(0, 6)
        corner.Parent = textBox

        local function toggleBox()
            textBox.Visible = not textBox.Visible
            if textBox.Visible then
                textBox:CaptureFocus()
            end
        end

        toggleButton.MouseButton1Click:Connect(toggleBox)

        UserInputService.InputBegan:Connect(function(input, gameProcessed)
            if input.KeyCode == Enum.KeyCode.Semicolon then
                toggleBox()
            end
        end)

        textBox.FocusLost:Connect(function(enterPressed)
            if enterPressed then
                local cmd = textBox.Text
                if cmd ~= "" then
                    textBox.Text = ""
                    textBox.Visible = false
                    if cmd:sub(1, 1) ~= "!" then
                        cmd = "!" .. cmd
                    end
                    processCommand(cmd, LocalPlayer)
                end
            end
        end)

        if syn and syn.protect_gui then
            syn.protect_gui(screenGui)
            screenGui.Parent = CoreGui
        elseif gethui then
            screenGui.Parent = gethui()
        else
            screenGui.CoreGui = CoreGui
            screenGui.Parent = CoreGui
        end
    end)
end)

task.spawn(function()
    local triggered = false
    while true do
        task.wait(1)
        if autoDonating and not isCommander(LocalPlayer) then
            pcall(function()
                local leaderstats = LocalPlayer:FindFirstChild("leaderstats")
                local timeStat = nil
                if leaderstats then
                    timeStat = leaderstats:FindFirstChild("Time") 
                        or leaderstats:FindFirstChild("PlayTime") 
                        or leaderstats:FindFirstChild("OnlineTime")
                end
                
                if timeStat then
                    if timeStat.Value >= autoDonateGoal and not triggered then
                        triggered = true
                        safeSendChat("Donate " .. autoDonateTarget .. " " .. tostring(timeStat.Value))
                    elseif timeStat.Value < autoDonateGoal then
                        triggered = false
                    end
                end
            end)
        end
    end
end)

task.spawn(function()
    while true do
        task.wait(60)
        if antiIdleEnabled and not isCommander(LocalPlayer) then
            pcall(function()
                VirtualUser:Button1Down(Vector2.new(0,0), workspace.CurrentCamera.CFrame)
                task.wait(0.1)
                VirtualUser:Button1Up(Vector2.new(0,0), workspace.CurrentCamera.CFrame)
            end)
        end
    end
end)

RunService.Heartbeat:Connect(function()
    pcall(updateFormations)
    if not isCommander(LocalPlayer) then
        pcall(function() if setfpscap then setfpscap(30) end end)
    end

    if antiFreezeEnabled then
        local character = LocalPlayer.Character
        if character then
            local humanoid = character:FindFirstChildOfClass("Humanoid")
            local rootPart = character:FindFirstChild("HumanoidRootPart")
            if humanoid and rootPart then
                if not rootPart.Anchored and humanoid.Health > 0 then
                    lastValidCFrame = rootPart.CFrame
                end
                if rootPart.Anchored or humanoid.PlatformStand then
                    stuckTime = stuckTime + RunService.Heartbeat:Wait()
                    if stuckTime > 0.5 then
                        stuckTime = 0
                        humanoid.Health = 0
                    end
                else
                    stuckTime = 0
                end
            end
        end
    end
end)

LocalPlayer.CharacterAdded:Connect(function(newCharacter)
    if congaing or orbiting or liningUp or stacking or walling then
        task.wait(1)
        congaStartTime = os.clock()
        orbitStartTime = os.clock()
        stuckTime = 0
    end
    if antiFreezeEnabled and lastValidCFrame then
        task.spawn(function()
            local rootPart = newCharacter:WaitForChild("HumanoidRootPart", 3)
            if rootPart then
                task.wait(0.1)
                rootPart.CFrame = lastValidCFrame
            end
        end)
    end
end)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: