Zombie Attack - Zombie Attack Script.lua
local a=8;local b=game:GetService('Players').LocalPlayer;local function c()local d,e=nil,99999;for f,g in pairs(game.Workspace.BossFolder:GetChildren())do if g:FindFirstChild('Head')~=nil then local h=(b.Character.Head.Position-g.Head.Position).magnitude;if h<e then e=h;d=g end end end;for f,g in pairs(game.Workspace.enemies:GetChildren())do if g:FindFirstChild('Head')~=nil then local h=(b.Character.Head.Position-g.Head.Position).magnitude;if h<e then e=h;d=g end end end;return d end;_G.farm2=true;b.Chatted:Connect(function(h)if h==';autofarm false'then _G.farm2=false elseif h==';autofarm true'then _G.farm2=true end end)_G.globalTarget=nil;game:GetService('RunService').RenderStepped:Connect(function()if _G.farm2==true then local i=c()if i~=nil then game:GetService('Workspace').CurrentCamera.CFrame=CFrame.new(game:GetService('Workspace').CurrentCamera.CFrame.p,i.Head.Position)b.Character.HumanoidRootPart.CFrame=i.HumanoidRootPart.CFrame*CFrame.new(0,a,9)_G.globalTarget=i end end end)spawn(function()while wait()do game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity=Vector3.new(0,0,0)game.Players.LocalPlayer.Character.Torso.Velocity=Vector3.new(0,0,0)end end)while wait()do if _G.farm2==true and _G.globalTarget~=nil and _G.globalTarget:FindFirstChild('Head')and b.Character:FindFirstChildOfClass('Tool')then local i=_G.globalTarget;game.ReplicatedStorage.Gun:FireServer({['Normal']=Vector3.new(0,0,0),['Direction']=i.Head.Position,['Name']=b.Character:FindFirstChildOfClass('Tool').Name,['Hit']=i.Head,['Origin']=i.Head.Position,['Pos']=i.Head.Position})wait()end end