script open source
Key Required

script open source

Zombie Attackdandushdandush 4.3K views 101 executesUpdated Oct 8, 2025
1.7/ 5(6 votes)
2433% Positive
Lua Script•235 lines (7313 chars)
local Rayfield = loadstring(game:HttpGet('https://sirius.menu/rayfield'))()
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local replicatedStorage = game:GetService("ReplicatedStorage")
local gunRemote = replicatedStorage.Gun
local TS = game:GetService("TweenService")
local workspace = game:GetService("Workspace")
local auto_farm = false
local RunService = game:GetService("RunService")
local zombieHeightOffset = 12
local gunDataPath = replicatedStorage:WaitForChild("GunData")
local gunDataModule = require(gunDataPath)
local antiAfk = false
local weaponName
local prevZombie = nil
local blockedZombies = {}
local zombieToCount = nil
local zombieTimer = 0
local unfocusTimeZombie = 30
local unfocusTimeBoss = 100


local Window = Rayfield:CreateWindow({
   Name = "Zombie Attack GUI",
   Icon = 0,
   LoadingTitle = "Rayfield Interface Suite",
   LoadingSubtitle = "by Sirius",
   Theme = "Default",
   ToggleUIKeybind = "G",
   DisableRayfieldPrompts = false,
   DisableBuildWarnings = false,
   ConfigurationSaving = {
      Enabled = true,
      FolderName = nil,
      FileName = "ZombieAttack"
   },
})



player.CharacterAdded:Connect(function(newCharacter)
    character = newCharacter
    HRP = character:WaitForChild("HumanoidRootPart")
    humanoid = character:WaitForChild("Humanoid")
end)

local function shootTarget(Zombie, Gun)
    local args = {
        [1] = {
            ["Normal"] = Vector3.new(0, 0, 0),
            ["Direction"] = Zombie.Head.Position,
            ["Name"] = Gun,
            ["Hit"] = Zombie.Head,
            ["Origin"] = Zombie.Head.Position,
            ["Pos"] = Zombie.Head.Position
        }
    }
    gunRemote:FireServer(unpack(args))
end

local function getWeaponStats(Name : string)
    local result = gunDataModule[Name]
    if not result then
        warn("Didnt Find Result For: ",Name)
    end
    return gunDataModule[Name]
end

local VirtalInputService = game:GetService("VirtualInputManager")

local autoFarmTab = Window:CreateTab("Auto Farm","rewind")



autoFarmTab:CreateToggle({
    
    Name = "Auto Kill Zombies",
    CurrentValue = false,
    Callback = function(state)
        auto_farm = state
        task.wait()
        print("Set auto_farm to",tostring(auto_farm))
    end,
})


autoFarmTab:CreateToggle({
    Name = "Anti AFK",
    CurrentValue = false,
    Callback = function(state)
        antiAfk = state
    end,
})

local function findWeapon()
    for _, container in pairs({player.Backpack, character}) do
        for _,item in pairs(container:GetChildren()) do
            if item:FindFirstChild("GunController") then
                if item.Name ~= "Guns" then
                    return item.Name
                end
            end
        end
    end
    warn("Didnt Find Gun, possibly in lobby")
    return nil
end

local function equipWeapon(weaponName)
    warn("Equipping Gun!")
    local tool = player.Backpack:FindFirstChild(weaponName) or character:FindFirstChild(weaponName)
    if tool then
        tool.Parent = character
    end
end

local function getHighestZombie(zombieToCompare)
    local highestY = -9999999
    local highestZombie = nil
    if zombieToCompare then
        for _,zombie in pairs(workspace.enemies:GetChildren()) do
            local Head = zombie:FindFirstChild("Head")
            local otherHead = zombieToCompare:FindFirstChild("Head")
            if Head and otherHead then
                if Head.Position.Y > highestY and Head.Position.Y < 1000 then
                    if (zombie.Head.Position - zombieToCompare.Head.Position).Magnitude < 25 then
                        if not(table.find(blockedZombies,zombie)) then
                            highestY = Head.Position.Y 
                            highestZombie = zombie
                        end
                    end
                end
            end
        end
    elseif not highestZombie or not zombieToCompare then
        for _,zombie in pairs(workspace.enemies:GetChildren()) do
            local Head = zombie:FindFirstChild("Head")
            if Head then
                if Head.Position.Y > highestY then
                    highestY = Head.Position.Y 
                    highestZombie = zombie
                end
            end
        end
    end
    return highestZombie
end
local testTab = Window:CreateTab("Test Tab", "rewind")
testTab:CreateSection("Weapon")
testTab:CreateButton({
    Name = "Get Weapon",
    Callback = function()
        weaponName = findWeapon()
        if weaponName then
            warn("Weapon found:" , weaponName)
            Rayfield:Notify({
                Title = "Weapon Found",
                Content = "Weapon:" , weaponName, " has been found.",
                Duration = 5,
                Image = 0
            })

        else
            warn("No weapon found, possibly in lobby?")
        end
    end,
})

spawn(function()
    local lastTime = tick()
    while true do
        if auto_farm then
                local currentTime = tick()
                local deltaTime = currentTime - lastTime
                lastTime = currentTime
                weaponName = findWeapon()
                if weaponName then
                local autoFarmZombie
                if prevZombie then
                autoFarmZombie = getHighestZombie(prevZombie)
                else
                autoFarmZombie = getHighestZombie(nil)
                end
                zombieTimer += deltaTime
                zombieToCount = autoFarmZombie
                prevZombie = autoFarmZombie
                local boss = workspace.BossFolder:GetChildren()[1]

                if autoFarmZombie and not boss then
                    if zombieTimer > unfocusTimeZombie then
                        table.insert(blockedZombies,zombieToCount)
                        zombieToCount = nil
                        zombieTimer = 0
                    end
                end  
                if boss then
                    HRP.CFrame = boss.Head.CFrame + Vector3.new(math.random(0,10),zombieHeightOffset,math.random(0,10))
                    equipWeapon(weaponName)
                    shootTarget(boss, weaponName)
                elseif autoFarmZombie then
                    HRP.CFrame = autoFarmZombie.Head.CFrame + Vector3.new(0,zombieHeightOffset,0)
                    equipWeapon(weaponName)
                    shootTarget(autoFarmZombie, weaponName)
                else
                    warn("Zombie or Boss Not Found")
                end
            end
        end  
        if weaponName then
            task.wait(1/ (getWeaponStats(weaponName).Firerate))
        else
            task.wait(1)
        end
    end
end)

local connection = RunService.Stepped:Connect(function()
    if auto_farm then
    HRP.Velocity = Vector3.zero
    character.Torso.Velocity = Vector3.zero
    end
end)

spawn(function()
    while wait(600) do
        if antiAfk then
            VirtalInputService:SendKeyEvent(true, Enum.KeyCode.M, false, nil)
            wait(0.1)
            VirtalInputService:SendKeyEvent(false, Enum.KeyCode.M, false, nil)
        end      
    end
end)

Features & Information

open source with rayfield ui , was created for teaching someone else
#zombieattack#opensource#autofarm

Community Comments (3)

IamJoshIamJoshOct 8, 2025

Terrible

Merk23Merk23Oct 9, 2025

Make auto kill aura only and can kill player if you zombie 🙂

Replying to @Merk23
dandushdandushOct 9, 2025

@Merk23 i created this a while ago only for auto farm, i cant add something new right now, sorry

More Scripts for Zombie Attack