Sword Fighting Bot v1
Key RequiredUniversal

Sword Fighting Bot v1

Universal ScriptOriginalStarlightOriginalStarlight 754 views 359 executesUpdated Feb 4, 2026
0.0/ 5(1 votes)
010% Positive
Lua Script•467 lines (16884 chars)
-- Services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local PathfindingService = game:GetService("PathfindingService")

-- Configuration
local Settings = {
    Enabled = false,
    AutoLook = false,
    Range = 50,
    MaxRange = 50,
    MinRange = 0,
    MenuOpen = false,
    MissChance = 12,
    TargetMode = "All", -- Options: "All", "Players", "NPCs"
    WhitelistedPlayers = {} -- Add UserIds here
}

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local isEquipping = false
local lastPos = Vector3.zero
local stuckTicks = 0
local path = PathfindingService:CreatePath({AgentCanJump = true, AgentRadius = 3})

-- [[ ESP HIGHLIGHT SETUP ]] --
local targetHighlight = Instance.new("Highlight")
targetHighlight.Name = "SystemTargetESP"
targetHighlight.FillColor = Color3.fromRGB(255, 0, 0)
targetHighlight.OutlineColor = Color3.fromRGB(255, 255, 255)
targetHighlight.FillTransparency = 0.5
targetHighlight.OutlineTransparency = 0

-- [[ STAFF DETECTOR / PANIC FUNCTION ]] --
local function triggerPanic()
    Settings.Enabled = false
    targetHighlight.Parent = nil
    local gui = playerGui:FindFirstChild("CoreGui")
    if gui then gui:Destroy() end
end

local function checkAdmin(plr)
    if plr.UserId == game.CreatorId or plr:GetRankInGroup(game.CreatorId) >= 200 then
        triggerPanic()
    end
end

Players.PlayerAdded:Connect(checkAdmin)
for _, plr in ipairs(Players:GetPlayers()) do checkAdmin(plr) end

-- [[ CHAT SECURITY LOGIC ]] --
local function handleChat(sender, message)
    local msg = message:lower()
    local user = player.Name:lower()
    local display = player.DisplayName:lower()
    
    if msg:find("hacker") then
        if sender ~= player or msg:find(user) or msg:find(display) then
            player:Kick("Tattle tail detected")
        end
    end
end

Players.PlayerChatted:Connect(function(chatType, sender, message)
    handleChat(sender, message)
end)

-- GUI Initialization
if playerGui:FindFirstChild("CoreGui") then playerGui.CoreGui:Destroy() end

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CoreGui"
screenGui.ResetOnSpawn = false
screenGui.IgnoreGuiInset = true
screenGui.Parent = playerGui

-- Topbar System Pill
local topPill = Instance.new("Frame")
topPill.Name = "SystemPill"
topPill.Size = UDim2.new(0, 90, 0, 38)
topPill.Position = UDim2.new(0, 340, 0, 15)
topPill.BackgroundColor3 = Color3.fromRGB(18, 18, 18)
topPill.BackgroundTransparency = 0.1
topPill.Parent = screenGui
Instance.new("UICorner", topPill).CornerRadius = UDim.new(0, 12)

local pillButton = Instance.new("TextButton")
pillButton.Size = UDim2.new(1, 0, 1, 0)
pillButton.BackgroundTransparency = 1
pillButton.Text = "System"
pillButton.TextColor3 = Color3.new(1, 1, 1)
pillButton.Font = Enum.Font.BuilderSansBold
pillButton.TextSize = 14
pillButton.Parent = topPill

-- Panic Button
local panicPill = Instance.new("Frame")
panicPill.Size = UDim2.new(0, 38, 0, 38)
panicPill.Position = UDim2.new(0, 435, 0, 15)
panicPill.BackgroundColor3 = Color3.fromRGB(18, 18, 18)
panicPill.BackgroundTransparency = 0.1
panicPill.Parent = screenGui
Instance.new("UICorner", panicPill).CornerRadius = UDim.new(0, 12)

local panicButton = Instance.new("TextButton")
panicButton.Size = UDim2.new(1, 0, 1, 0)
panicButton.BackgroundTransparency = 1
panicButton.Text = "P"
panicButton.TextColor3 = Color3.new(1, 1, 1)
panicButton.Font = Enum.Font.BuilderSansBold
panicButton.TextSize = 14
panicButton.Parent = panicPill

-- Target HUD
local targetHud = Instance.new("TextLabel")
targetHud.Size = UDim2.new(0, 150, 0, 25)
targetHud.Position = UDim2.new(0, 310, 0, 175) 
targetHud.BackgroundColor3 = Color3.fromRGB(18, 18, 18)
targetHud.BackgroundTransparency = 0.1
targetHud.TextColor3 = Color3.new(1, 1, 1)
targetHud.Font = Enum.Font.BuilderSansMedium
targetHud.TextSize = 12
targetHud.Visible = false
targetHud.Parent = screenGui
Instance.new("UICorner", targetHud).CornerRadius = UDim.new(0, 8)

-- Main Menu
local mainFrame = Instance.new("Frame")
mainFrame.Visible = false
mainFrame.Size = UDim2.new(0, 190, 0, 240) 
mainFrame.AnchorPoint = Vector2.new(0.5, 0) 
mainFrame.Position = UDim2.new(0, 385, 0, 60) 
mainFrame.BackgroundColor3 = Color3.fromRGB(18, 18, 18)
mainFrame.BackgroundTransparency = 0.1
mainFrame.Active = true
mainFrame.Draggable = true 
mainFrame.Parent = screenGui
Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 12)

local function CreateSettingRow(text, pos)
    local btn = Instance.new("TextButton")
    btn.Size = UDim2.new(0.92, 0, 0, 38)
    btn.Position = pos
    btn.BackgroundColor3 = Color3.fromRGB(38, 38, 38)
    btn.BackgroundTransparency = 1
    btn.Text = text
    btn.TextColor3 = Color3.new(1, 1, 1)
    btn.Font = Enum.Font.BuilderSansMedium
    btn.TextSize = 14
    btn.Parent = mainFrame
    Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 8)
    return btn
end

local toggleBtn = CreateSettingRow("Combat Logic: OFF", UDim2.new(0.04, 0, 0, 10))
local lookBtn = CreateSettingRow("Auto Face: OFF", UDim2.new(0.04, 0, 0, 55))
local modeBtn = CreateSettingRow("Targets: All", UDim2.new(0.04, 0, 0, 100))

local rangeInput = Instance.new("TextBox")
rangeInput.Size = UDim2.new(0.92, 0, 0, 38)
rangeInput.Position = UDim2.new(0.04, 0, 0, 145)
rangeInput.BackgroundColor3 = Color3.fromRGB(38, 38, 38)
rangeInput.BackgroundTransparency = 1
rangeInput.Text = "50" 
rangeInput.PlaceholderText = "Range (0-50)"
rangeInput.TextColor3 = Color3.new(1, 1, 1)
rangeInput.Font = Enum.Font.BuilderSans
rangeInput.TextSize = 14
rangeInput.TextXAlignment = Enum.TextXAlignment.Center
rangeInput.ClearTextOnFocus = true
rangeInput.Parent = mainFrame
Instance.new("UICorner", rangeInput).CornerRadius = UDim.new(0, 8)

local missInput = Instance.new("TextBox")
missInput.Size = UDim2.new(0.92, 0, 0, 38)
missInput.Position = UDim2.new(0.04, 0, 0, 190)
missInput.BackgroundColor3 = Color3.fromRGB(38, 38, 38)
missInput.BackgroundTransparency = 1
missInput.Text = "12" 
missInput.PlaceholderText = "Miss Chance (0-12)"
missInput.TextColor3 = Color3.new(1, 1, 1)
missInput.Font = Enum.Font.BuilderSans
missInput.TextSize = 14
missInput.TextXAlignment = Enum.TextXAlignment.Center
missInput.ClearTextOnFocus = true
missInput.Parent = mainFrame
Instance.new("UICorner", missInput).CornerRadius = UDim.new(0, 8)

--- [[ NAVIGATION LOGIC ]] ---

local function IsVisible(start, targetPart)
    local params = RaycastParams.new()
    params.FilterDescendantsInstances = {player.Character, targetPart.Parent}
    params.FilterType = Enum.RaycastFilterType.Exclude
    local result = workspace:Raycast(start, (targetPart.Position - start).Unit * 100, params)
    return result == nil
end

local function GetGroundCheck(pos)
    local ray = Ray.new(pos, Vector3.new(0, -20, 0))
    local hit, hitPos = workspace:FindPartOnRayWithIgnoreList(ray, {player.Character})
    return hit
end

local function IsForwardSafe(root, direction)
    local lookDist = 7
    local checkPos = root.Position + (direction.Unit * lookDist)
    local ground = GetGroundCheck(checkPos)
    local wallRay = Ray.new(root.Position + Vector3.new(0, 0, 0), direction.Unit * lookDist)
    local wall = workspace:FindPartOnRayWithIgnoreList(wallRay, {player.Character})
    local highWallRay = Ray.new(root.Position + Vector3.new(0, 4.5, 0), direction.Unit * lookDist)
    local highWall = workspace:FindPartOnRayWithIgnoreList(highWallRay, {player.Character})
    return (ground ~= nil), (wall ~= nil), (highWall ~= nil)
end

local function GetSmartMovePos(root, hum, targetPos)
    if (root.Position - lastPos).Magnitude < 0.05 then
        stuckTicks = stuckTicks + 1
    else
        stuckTicks = 0
    end
    lastPos = root.Position
    
    if stuckTicks > 40 then
        hum.Jump = true
        stuckTicks = 0
        return root.Position + (root.CFrame.RightVector * math.random(-6, 6)) + (root.CFrame.LookVector * -2)
    end

    local dirToTarget = (targetPos - root.Position).Unit
    local isSafe, isBlocked, isHighBlocked = IsForwardSafe(root, dirToTarget)
    
    local leftEdge = GetGroundCheck(root.Position + (root.CFrame.RightVector * -2) + (dirToTarget * 2.5))
    local rightEdge = GetGroundCheck(root.Position + (root.CFrame.RightVector * 2) + (dirToTarget * 2.5))
    
    if not leftEdge and rightEdge then
        return root.Position + (root.CFrame.RightVector * 2.5)
    elseif leftEdge and not rightEdge then
        return root.Position + (root.CFrame.RightVector * -2.5)
    end

    if (isBlocked and not isHighBlocked) or (not isSafe) then
        hum.Jump = true
    end

    if isBlocked and isHighBlocked then
        local sideDir = (CFrame.new(Vector3.zero, dirToTarget) * CFrame.Angles(0, math.rad(90), 0)).LookVector
        if IsForwardSafe(root, sideDir) then return root.Position + (sideDir * 12) end
    end
    
    return targetPos
end

--- [[ INTERFACE LOGIC ]] ---

pillButton.MouseButton1Click:Connect(function()
    Settings.MenuOpen = not Settings.MenuOpen
    mainFrame.Visible = Settings.MenuOpen
end)

panicButton.MouseButton1Click:Connect(triggerPanic)

toggleBtn.MouseButton1Click:Connect(function()
    Settings.Enabled = not Settings.Enabled
    toggleBtn.Text = Settings.Enabled and "Combat Logic: ON" or "Combat Logic: OFF"
end)

lookBtn.MouseButton1Click:Connect(function()
    Settings.AutoLook = not Settings.AutoLook
    lookBtn.Text = Settings.AutoLook and "Auto Face: ON" or "Auto Face: OFF"
end)

modeBtn.MouseButton1Click:Connect(function()
    if Settings.TargetMode == "All" then
        Settings.TargetMode = "Players"
    elseif Settings.TargetMode == "Players" then
        Settings.TargetMode = "NPCs"
    else
        Settings.TargetMode = "All"
    end
    modeBtn.Text = "Targets: " .. Settings.TargetMode
end)

-- Keybind Listener
UserInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    if input.KeyCode == Enum.KeyCode.RightControl then
        Settings.MenuOpen = not Settings.MenuOpen
        mainFrame.Visible = Settings.MenuOpen
    elseif input.KeyCode == Enum.KeyCode.P then
        triggerPanic()
    elseif input.KeyCode == Enum.KeyCode.T then
        Settings.Enabled = not Settings.Enabled
        toggleBtn.Text = Settings.Enabled and "Combat Logic: ON" or "Combat Logic: OFF"
    end
end)

-- Auto-Reconnect on Respawn
player.CharacterAdded:Connect(function()
    isEquipping = false
    stuckTicks = 0
end)

-- Real-time validation for Range (Hard Cap 50)
rangeInput:GetPropertyChangedSignal("Text"):Connect(function()
    local clean = rangeInput.Text:gsub("%D+", "")
    local num = tonumber(clean)
    if num and num > 50 then 
        rangeInput.Text = "50" 
    else
        rangeInput.Text = clean
    end
end)

rangeInput.FocusLost:Connect(function()
    local val = tonumber(rangeInput.Text)
    Settings.Range = math.clamp(val or 50, 0, 50)
    rangeInput.Text = tostring(Settings.Range)
end)

-- Real-time validation for Miss Chance (Hard Cap 12)
missInput:GetPropertyChangedSignal("Text"):Connect(function()
    local clean = missInput.Text:gsub("%D+", "")
    local num = tonumber(clean)
    if num and num > 12 then 
        missInput.Text = "12" 
    else
        missInput.Text = clean
    end
end)

missInput.FocusLost:Connect(function()
    local val = tonumber(missInput.Text)
    Settings.MissChance = math.clamp(val or 12, 0, 12)
    missInput.Text = tostring(Settings.MissChance)
end)

--- [[ MAIN LOOP ]] ---

RunService.Heartbeat:Connect(function()
    if not Settings.Enabled or not screenGui.Parent then 
        targetHud.Visible = false 
        targetHighlight.Parent = nil
        return 
    end
    
    local char = player.Character
    local hum = char and char:FindFirstChildOfClass("Humanoid")
    local root = char and char:FindFirstChild("HumanoidRootPart")
    
    if not char or not hum or not root or hum.Health <= 0 then 
        targetHighlight.Parent = nil
        return 
    end
    
    local tool = char:FindFirstChildOfClass("Tool")
    
    if not tool and not isEquipping and player:FindFirstChild("Backpack") then
        local bpTool = player.Backpack:FindFirstChildOfClass("Tool")
        if bpTool then
            isEquipping = true
            hum:MoveTo(root.Position) 
            task.delay(math.random(3, 8) / 10, function()
                if Settings.Enabled and bpTool.Parent == player.Backpack then bpTool.Parent = char end
                isEquipping = false
            end)
        end
    end
    
    if isEquipping then return end

    local closestTarget, shortestDist = nil, Settings.Range
    local roamingTarget, roamingDist = nil, 400

    local scanList = Settings.TargetMode == "Players" and Players:GetPlayers() or workspace:GetDescendants()

    for _, obj in ipairs(scanList) do
        local charObj = obj:IsA("Player") and obj.Character or (obj:IsA("Humanoid") and obj.Parent or nil)
        if charObj and charObj ~= char then
            local tHum = charObj:FindFirstChildOfClass("Humanoid")
            local tRoot = charObj:FindFirstChild("HumanoidRootPart")
            
            if tHum and tHum.Health > 0 and tRoot then
                local isPlayer = Players:GetPlayerFromCharacter(charObj) ~= nil
                local isWhitelisted = isPlayer and table.find(Settings.WhitelistedPlayers, Players:GetPlayerFromCharacter(charObj).UserId)
                
                local allowed = false
                if not isWhitelisted then
                    if Settings.TargetMode == "All" then allowed = true
                    elseif Settings.TargetMode == "Players" and isPlayer then allowed = true
                    elseif Settings.TargetMode == "NPCs" and not isPlayer then allowed = true end
                end
                
                if allowed then
                    local dist = (root.Position - tRoot.Position).Magnitude
                    if dist <= shortestDist and IsVisible(root.Position, tRoot) then
                        closestTarget = charObj
                        shortestDist = dist
                    end
                    if dist < roamingDist then
                        roamingTarget = tRoot
                        roamingDist = dist
                    end
                end
            end
        end
    end

    if closestTarget and tool then
        local tRoot = closestTarget:FindFirstChild("HumanoidRootPart")
        local tHum = closestTarget:FindFirstChildOfClass("Humanoid")
        targetHud.Visible = true
        targetHud.Text = closestTarget.Name .. " [" .. math.floor(shortestDist) .. "m]"
        
        -- ESP Logic
        targetHighlight.Parent = closestTarget
        
        if Settings.AutoLook then
            hum.AutoRotate = false
            local predictedPos = tRoot.Position + (tRoot.Velocity * 0.18)
            local targetLook = CFrame.new(root.Position, Vector3.new(predictedPos.X, root.Position.Y, predictedPos.Z))
            root.CFrame = root.CFrame:Lerp(targetLook, 0.2)
            
            local movePos = tRoot.Position
            -- Coward Mode Logic (Health check)
            if hum.Health < 25 or tHum.MaxHealth >= 1000 then
                movePos = root.Position + (root.Position - tRoot.Position).Unit * 15
            end

            hum:MoveTo(GetSmartMovePos(root, hum, movePos))
            if tRoot.Position.Y > root.Position.Y + 3.5 then hum.Jump = true end
        end

        if math.random(1, 100) > Settings.MissChance then
            task.spawn(function()
                tool:Activate()
                if tool:FindFirstChild("Handle") then
                    firetouchinterest(tool.Handle, tRoot, 0)
                    firetouchinterest(tool.Handle, tRoot, 1)
                end
                local event = tool:FindFirstChild("RemoteEvent") or tool:FindFirstChild("Shoot") or tool:FindFirstChild("Fire")
                if event and event:IsA("RemoteEvent") then event:FireServer(tRoot.Position) end
            end)
        end
    else
        hum.AutoRotate = true
        targetHud.Visible = false
        targetHighlight.Parent = nil
        if roamingTarget and Settings.AutoLook then
            local success, err = pcall(function()
                path:ComputeAsync(root.Position, roamingTarget.Position)
            end)
            if success and path.Status == Enum.PathStatus.Success then
                local waypoints = path:GetWaypoints()
                if waypoints[2] then
                    hum:MoveTo(waypoints[2].Position)
                    if waypoints[2].Action == Enum.PathWaypointAction.Jump then hum.Jump = true end
                end
            else
                hum:MoveTo(GetSmartMovePos(root, hum, roamingTarget.Position))
            end
        else
            hum:MoveTo(root.Position) 
        end
    end
end)

Features & Information

Sword Fighting Bot

Community Comments (3)

ALTERRATICALTERRATICFeb 5, 2026

this doesnt do SHlT

Replying to @ALTERRATIC

@ALTERRATIC yes it does bruh

Replying to @OriginalStarlight
ALTERRATICALTERRATICFeb 6, 2026

@OriginalStarlight lying, tsk tsk

More Scripts for Universal Scripts