Sword fight bot universal modded by me
Key RequiredUniversal

Sword fight bot universal modded by me

Universal Scriptkunaflik7kunaflik7 6.9K views 148 executesUpdated Apr 26, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•300 lines (17914 chars)
_G.x = nil -- target, dont change e 
print("h:loaded (  :")
Grips = {
    Up = CFrame.new(1, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0), 
    Out = CFrame.new(1, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1) 
}

_G.e = nil
_G.rage = 0
local h3 = 0
local h4 = true 
local h = 3
local h2 = 0
_G.g = nil
_G.pos = nil
local jo = 0
local jo2 = 1
hhh = nil
local jo3 = 0
local player = game.Players.LocalPlayer

-- Modified find closest function
local function findClosestHumanoidRootPart()
    local closestRootPart = nil
    local closestDistance = math.huge
    local localPlayerPosition = player.Character.HumanoidRootPart.Position

    for _, part in pairs(workspace:GetDescendants()) do
        if part:IsA("BasePart") and part.Name == "HumanoidRootPart" and part.Parent ~= player.Character then
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            if humanoid and humanoid.Health > 0 then
                local distance = (part.Position - localPlayerPosition).Magnitude
                if distance < closestDistance then
                    closestDistance = distance
                    closestRootPart = part.Parent
                end
            end
        end
    end
    return closestRootPart
end

-- New improved auto-target function
local function autoTarget()
    local closestRootPart = findClosestHumanoidRootPart()
    
    -- Check current target validity
    if _G.x and (_G.x:FindFirstChild("Humanoid") == nil or _G.x.Humanoid.Health <= 0) then
        _G.x = nil
    end

    if closestRootPart then
        if _G.x and _G.x:FindFirstChild("HumanoidRootPart") and _G.x.Humanoid.Health > 0 then
            -- Compare distances
            local currentDist = (_G.x.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude
            local closestDist = (closestRootPart.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude
            
            -- Switch target if someone closer exists
            if closestRootPart ~= _G.x and closestDist < currentDist then
                _G.x = closestRootPart
                print("Switched to closer target: " .. _G.x.Name)
                game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
                    Text = "Switched target to: " .. _G.x.Name,
                    Color = Color3.fromRGB(0, 255, 255),
                    Font = Enum.Font.SourceSansBold,
                    TextSize = 18
                })
            end
        else
            -- Set new target
            _G.x = closestRootPart
            if _G.x then
                print("Auto-targeting: " .. _G.x.Name)
                game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
                    Text = "Auto-targeting: " .. _G.x.Name,
                    Color = Color3.fromRGB(0, 255, 255),
                    Font = Enum.Font.SourceSansBold,
                    TextSize = 18
                })
            end
        end
    else
        _G.x = nil
    end
end

-- RunService remains same but now uses improved targeting
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
    if _G.y == 1 and _G.rage == 0 then
        autoTarget()
    end
end)

-- Rest of original script remains unchanged below this line
local numba = Instance.new("NumberValue", workspace)
numba.Value = -40
delay(0, function()
    while true do
        wait(0.14)
        numba.Value = math.random(-90, -10) 
        game.TweenService:Create(numba, TweenInfo.new(0.07, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 1, true, 0), { Value = math.random(35, 90) }):Play()
    end
end)

delay(5, function()
    bg = Instance.new("BodyGyro", game.ReplicatedStorage)
    bg.D = 1
    bg.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector)
    bg.P = 9999999999
    bg.MaxTorque = Vector3.new(400000000000000, 40000000000000, 400000000000000) 

    game:GetService("RunService").RenderStepped:Connect(function()
        if _G.x ~= nil and _G.x:FindFirstChild("HumanoidRootPart") and _G.y == 1 and player.Character and player.Character.Humanoid.Health > 0 then
            if _G.x:FindFirstChild("Humanoid") and _G.x.Humanoid.Health > 0 then
                bg.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
                local torso = player.Character.HumanoidRootPart.CFrame.p + player.Character.HumanoidRootPart.CFrame.LookVector * 1 + player.Character.HumanoidRootPart.CFrame.RightVector * 1
                local torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / 1000 
                if h2 == 0 then
                    torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / -1000 
                elseif h2 == 1 then
                    torso2 = _G.x.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * (numba.Value / 25)
                end
                bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0))
                _G.pos = _G.x["HumanoidRootPart"].Position + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * 0 + player.Character["HumanoidRootPart"].CFrame.RightVector * 6

                if _G.x.HumanoidRootPart.Position.y - 0.5 > player.Character.HumanoidRootPart.Position.y then
                    delay(0, function() player.Character.Humanoid.Jump = true end)
                end
                if _G.x.HumanoidRootPart.Velocity.z >= player.Character.HumanoidRootPart.CFrame.LookVector.z or _G.x.HumanoidRootPart.Velocity.x >= player.Character.HumanoidRootPart.CFrame.LookVector.x then
                    _G.pos = _G.x["HumanoidRootPart"].Position + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + player.Character["HumanoidRootPart"].CFrame.RightVector * 6 - _G.x.HumanoidRootPart.Velocity / 120
                    local torso = player.Character.HumanoidRootPart.CFrame.p + player.Character.HumanoidRootPart.CFrame.LookVector * 1 + player.Character.HumanoidRootPart.CFrame.RightVector * 1
                    local torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / -1000 
                    if h2 == 0 then
                        torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / 1000 
                    elseif h2 == 1 then
                        torso2 = _G.x.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * (numba.Value / 25)
                    end
                    bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0))
                    if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 10 then
                        _G.pos = _G.x["HumanoidRootPart"].Position + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + (player.Character["HumanoidRootPart"].CFrame.RightVector * 1 + player.Character["HumanoidRootPart"].CFrame.LookVector * -1) - _G.x.HumanoidRootPart.Velocity / 5 + player.Character.HumanoidRootPart.CFrame.RightVector * h
                        jo = jo + 1
                        if jo == 1 then 
                            h = h * -1
                        end
                    end
                elseif _G.x.HumanoidRootPart.Velocity.z <= player.Character.HumanoidRootPart.CFrame.LookVector.z or _G.x.HumanoidRootPart.Velocity.x <= player.Character.HumanoidRootPart.CFrame.LookVector.x then
                    _G.pos = _G.x["HumanoidRootPart"].Position + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + player.Character["HumanoidRootPart"].CFrame.RightVector * 6 + _G.x.HumanoidRootPart.Velocity / 200
                    local torso = player.Character.HumanoidRootPart.CFrame.p + player.Character.HumanoidRootPart.CFrame.LookVector * 1 + player.Character.HumanoidRootPart.CFrame.RightVector * 1
                    local torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / 1000 
                    if h2 == 0 then
                        torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / -1000 
                    elseif h2 == 1 then
                        torso2 = _G.x.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * (numba.Value / 25)
                    end
                    bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0))
                    if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 10 then
                        _G.pos = _G.x["HumanoidRootPart"].Position + _G.x["HumanoidRootPart"].CFrame.RightVector * 1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + (player.Character["HumanoidRootPart"].CFrame.RightVector * 1 + player.Character["HumanoidRootPart"].CFrame.LookVector * -1) + _G.x.HumanoidRootPart.Velocity / 3 + player.Character.HumanoidRootPart.CFrame.RightVector * h
                        jo = jo + 1
                        if jo == 1 then 
                            h = h * -1
                        end
                    end
                end
                if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 10 then
                    h2 = 1
                else
                    h2 = 0
                end
                if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 20 then
                    if (_G.x["HumanoidRootPart"].Position - player.Character["Right Arm"].CFrame.p).magnitude <= 5 or hhh == true then
                        hhh = true
                        if (_G.x["HumanoidRootPart"].Position - player.Character["Right Arm"].CFrame.p).magnitude >= 7 then
                            hhh = false
                        end
                        jo3 = jo3 + 2 
                        if jo3 >= math.random(2,10) then 
                            jo3 = 0 
                            if jo2 == 1 then 
                                jo2 = -2
                            else
                                jo2 = 0
                            end
                        end
                        _G.pos = player.Character["HumanoidRootPart"].CFrame.LookVector * 5 * jo2 + _G.x.HumanoidRootPart.Velocity / 20
                        if _G.x.HumanoidRootPart.Velocity.z >= player.Character.HumanoidRootPart.CFrame.LookVector.z or _G.x.HumanoidRootPart.Velocity.x >= player.Character.HumanoidRootPart.CFrame.LookVector.x then
                            _G.pos = player.Character["HumanoidRootPart"].CFrame.LookVector * 5 * jo2 + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + player.Character["HumanoidRootPart"].CFrame.RightVector * 6 - _G.x.HumanoidRootPart.Velocity / 230
                            local torso = player.Character.HumanoidRootPart.CFrame.p + player.Character.HumanoidRootPart.CFrame.LookVector * 1 + player.Character.HumanoidRootPart.CFrame.RightVector * 1
                            local torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / 1000 
                            if h2 == 0 then
                                torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / -1000 
                            elseif h2 == 1 then
                                torso2 = _G.x.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * (numba.Value / 25)
                            end
                            bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0))
                            bg.D = 10000 
                            if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 10 then
                                _G.pos = player.Character["HumanoidRootPart"].CFrame.LookVector * 5 * jo2 + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + (player.Character["HumanoidRootPart"].CFrame.RightVector * 1 + player.Character["HumanoidRootPart"].CFrame.LookVector * -1) - _G.x.HumanoidRootPart.Velocity / 5 + player.Character.HumanoidRootPart.CFrame.RightVector * h
                                jo = jo + 1
                                if jo == 1 then 
                                    h = h * -1
                                end
                            end
                        elseif _G.x.HumanoidRootPart.Velocity.z <= player.Character.HumanoidRootPart.CFrame.LookVector.z or _G.x.HumanoidRootPart.Velocity.x <= player.Character.HumanoidRootPart.CFrame.LookVector.x then
                            _G.pos = player.Character["HumanoidRootPart"].CFrame.LookVector * 5 * jo2 + _G.x["HumanoidRootPart"].CFrame.RightVector * -1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + player.Character["HumanoidRootPart"].CFrame.RightVector * 6 + _G.x.HumanoidRootPart.Velocity / 300
                            local torso = player.Character.HumanoidRootPart.CFrame.p + player.Character.HumanoidRootPart.CFrame.LookVector * 1 + player.Character.HumanoidRootPart.CFrame.RightVector * 1
                            local torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / 1000 
                            if h2 == 0 then
                                torso2 = _G.x.HumanoidRootPart.Position + _G.x.HumanoidRootPart.Velocity / -1000 
                            elseif h2 == 1 then
                                torso2 = _G.x.HumanoidRootPart.Position + game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.RightVector * (numba.Value / 25)
                            end
                            bg.CFrame = CFrame.new(torso - Vector3.new(0, torso.y, 0), torso2 - Vector3.new(0, torso2.y, 0))
                            if (_G.x["HumanoidRootPart"].Position - player.Character["HumanoidRootPart"].CFrame.p).magnitude <= 10 then
                                _G.pos = player.Character["HumanoidRootPart"].CFrame.LookVector * 5 * jo2 + _G.x["HumanoidRootPart"].CFrame.RightVector * 1 + _G.x.HumanoidRootPart.CFrame.LookVector * -1 + (player.Character["HumanoidRootPart"].CFrame.RightVector * 1 + player.Character["HumanoidRootPart"].CFrame.LookVector * -1) + _G.x.HumanoidRootPart.Velocity / 3 + player.Character.HumanoidRootPart.CFrame.RightVector * h
                                jo = jo + 1
                                if jo == 1 then 
                                    h = h * -1
                                end
                            end
                        end
                        player.Character.Humanoid:Move(_G.pos)
                    end
                    if player.Character:FindFirstChildOfClass("Tool") then
                        player.Character:FindFirstChildOfClass("Tool"):Activate()
                    end
                end
                player.Character.Humanoid:MoveTo(_G.pos)
                if _G.x:FindFirstChildOfClass("Tool") and _G.x:FindFirstChildOfClass("Tool"):FindFirstChild("Handle") then
                end
            else
                _G.x = nil
            end
        else
            bg.Parent = game.ReplicatedStorage
        end
    end)
end)

mouse = player:GetMouse()
_G.e = game:GetService("UserInputService").InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.R then
        if _G.y == 1 then
            _G.y = 0
            print("Off y")
            game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
                Text = "y = " .. _G.y,
                Color = Color3.fromRGB(255, 255, 0),
                Font = Enum.Font.SourceSansBold,
                TextSize = 18
            })
        else
            _G.y = 1
            print("On y")
            game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
                Text = "y = " .. _G.y,
                Color = Color3.fromRGB(255, 255, 0),
                Font = Enum.Font.SourceSansBold,
                TextSize = 18
            })
            local succes, errorw = pcall(function()
            end)
            if not succes then
                warn(errorw)
                error(errorw)
            end
        end
    elseif key.KeyCode == Enum.KeyCode.T then
        if _G.rage == 0 then
            _G.rage = 1
        else
            _G.rage = 0
        end
        game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
            Text = "_G.rage = " .. _G.rage,
            Color = Color3.fromRGB(255, 255, 0),
            Font = Enum.Font.SourceSansBold,
            TextSize = 18
        })
    end
end)

while true do
    wait(0)
    if _G.rage == 0 then 
        local point1 = player.Character.HumanoidRootPart.Position + Vector3.new(-40, -100, -40) 
        local point2 = player.Character.HumanoidRootPart.Position + Vector3.new(40, 100, 40) 
        local region = Region3.new(point1, point2)
        local thing = workspace:FindPartsInRegion3(region, player.Character, math.huge)
        for i, v in pairs(thing) do
            if v.Parent:FindFirstChild("Humanoid") and v.Parent.Humanoid.Health > 0 then
                print(v.Name)
                _G.x = v.Parent
                _G.main()
                wait(0) 
                break
            end
        end
    end
end

Features & Information

Press r t (this is not mine lol I made it better so I keep updating it)

Community Comments (1)

kunaflik7kunaflik7Apr 26, 2025

Oh yea zzz

More Scripts for Universal Scripts