Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local parent = workspace.CurrentCamera
- local char = game.Players.LocalPlayer.Character
- repeat wait() char= game.Players.LocalPlayer.Character until char
- wait(1)
- char.Archivable = true
- local rootC = char.HumanoidRootPart
- local distance = 20
- local reach = 6
- local gyro = Instance.new("BodyGyro",rootC)
- gyro.MaxTorque = Vector3.new(0,math.huge,0)
- gyro.MaxTorque = Vector3.new(0,0,0)
- gyro.P = 10000
- gyro.D = 0
- local difficulty = 10
- local died = false
- local jumped = false
- local auto = false
- function run(charr)
- local find = charr:FindFirstChild("HumanoidRootPart")
- if find then
- local char = game.Players.LocalPlayer.Character
- local frame = CFrame.new(find.Position,char.HumanoidRootPart.Position)*CFrame.new(0,0,-distance+10)
- local pos = frame.Position
- char.Humanoid:MoveTo(pos)
- end
- end
- function onHealthChanged(health)
- if health == 0 and died == false then died = true
- warn("DIED")
- wait(game.Players.RespawnTime+.3)
- char= game.Players.LocalPlayer.Character
- repeat wait() char= game.Players.LocalPlayer.Character until char
- wait(.3)
- char.Archivable = true
- rootC = char.HumanoidRootPart
- reach = 7
- gyro= Instance.new("BodyGyro",rootC)
- gyro.MaxTorque = Vector3.new(0,0,0)
- gyro.P = 999999999999
- gyro.D = 0
- jumped = false
- local save = auto
- auto = false
- wait()
- if save == true then
- autoFight(distance)
- end
- died = false
- end
- end
- function attack(char2,sword)
- char = game.Players.LocalPlayer.Character
- if sword and sword.Parent == char and char:FindFirstChild("Humanoid")~=nil then
- --attacker is char2
- local root = char2:FindFirstChild("HumanoidRootPart")
- if root then
- if char2.Humanoid.Health>0 and char.Humanoid.Health>0 then
- local mag = (rootC.Position-root.Position).Magnitude
- local rag = root.CFrame:ToObjectSpace(rootC.CFrame)
- local rag2 = rootC.CFrame:ToObjectSpace(root.CFrame)
- local side = rag.Position.X
- local face = rag.Position.Z
- local top = rag.Position.Y
- --front face is in negative
- --side negative is left
- local convS = tostring(side)
- local convF = tostring(face)
- local findS = string.sub(convS,1,1)
- local findF = string.sub(convF,1,1)
- if rootC.Velocity.Magnitude >100 then
- print("velocity is too high")
- rootC.Velocity = Vector3.new(0,0,0)
- end
- if side<0 then
- if mag<=reach/2 then
- local rando = math.random(1,100)
- if rando == 100 then
- if jumped == false then jumped = true
- char.Humanoid.Jump = true
- jumped = false
- end
- end
- jumped = false
- local frame = CFrame.new(sword.Handle.Position,root.Parent["Left Arm"].Position)
- local mag2 = (rootC.Position-root.Parent["Left Arm"].Position).Magnitude
- local mag3 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
- if mag2<=reach/2 then
- jumped = false
- local framer = root.CFrame*CFrame.new(-2,0,-reach)
- if mag3<=reach/2 then
- print("may die")
- if jumped == false then jumped = true
- char.Humanoid.Jump = true
- jumped = false
- end
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach*2))).Position)
- else
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach))).Position)
- end
- gyro.CFrame = frame
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- else
- print("very close")
- jumped = false
- gyro.CFrame = frame
- frame = CFrame.new(sword.Handle.Position,root.Parent["Left Arm"].Position)
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- end
- else
- if mag<=reach then
- local mag2 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
- --[[if char2.Humanoid.Jump == true then
- char.Humanoid.Jump = true
- local framer = root.CFrame*CFrame.new(0,0,-2)
- local frame = CFrame.new(sword.Handle.Position,root.Position)
- gyro.CFrame = frame
- char.Humanoid:MoveTo((root.CFrame*CFrame.new(0,0,-reach)).Position)
- end]]
- if mag2<=reach then
- print("left arm vunerable")
- if jumped == false then jumped = true
- char.Humanoid.Jump = true
- jumped = false
- end
- local frame = CFrame.new(sword.Handle.Position,root.Position)
- gyro.CFrame = frame
- local framer = root.CFrame*CFrame.new(0,0,-reach)
- char.Humanoid:MoveTo(framer.Position)
- else
- print("within reach")
- local mag2 = (rootC.Position-root.Parent["Right Arm"].Position).Magnitude
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- local framer = root.CFrame*CFrame.new(0,0,-2)
- local frame = CFrame.new(sword.Handle.Position,root.Position)
- gyro.CFrame = frame
- framer = root.CFrame*CFrame.new(-4,0,-2)
- char.Humanoid:MoveTo(framer.Position)
- end
- else
- if mag<=reach*2 then
- jumped = false
- local mag2 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
- if mag2<=reach+((reach*2)/3) and rag2.Position.Y<=0 then
- print("left arm Semi-close")
- if jumped == false then jumped = true
- char.Humanoid.Jump = true
- end
- jumped = false
- local framer = root.CFrame*CFrame.new(0,0,-reach)
- char.Humanoid:MoveTo(framer.Position)
- local frame = CFrame.new(sword.Handle.Position,(root.Parent["Right Arm"].CFrame*CFrame.new(2,0,0)).Position)
- gyro.CFrame = frame
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(-4,0,-(reach*2))).Position)
- else
- print("approching")
- jumped = false
- local frame = CFrame.new(rootC.Position,root.Parent["Right Arm"].Position)
- local framer2 = CFrame.new(rootC.Position)*CFrame.Angles(0,math.rad(root.Orientation.Y)+math.pi,0)
- gyro.CFrame = framer2
- local hum = char.Humanoid
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- hum:MoveTo((root.CFrame*CFrame.new(0,0,-(reach))).Position)
- end
- else
- print("far away")
- jumped = false
- local frame = CFrame.new(rootC.Position,root.Parent["Right Arm"].Position)
- gyro.CFrame = frame
- char.Humanoid:MoveTo(root.Position)
- end
- end
- end
- else
- if face<=0 then
- if top>-7 then
- if side<4 then
- jumped = false
- local frame = CFrame.new(sword.Handle.Position,(root.Parent["Right Arm"].CFrame*CFrame.new(0,0,-1)).Position)
- local framer2 = CFrame.new(rootC.Position)*CFrame.Angles(0,math.rad(root.Orientation.Y)+math.pi,0)
- if mag<=reach*2 then
- print("coming close")
- gyro.CFrame = frame
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(1,0,-(reach))).Position)
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- else
- print("on wrong side")
- gyro.CFrame = frame
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach*2))).Position)
- end
- else
- if side>= 4 then
- print("coming from arm")
- local frame = CFrame.new(sword.Handle.Position,root.Parent["Right Arm"].Position)
- gyro.CFrame = frame
- local hum = char.Humanoid
- hum:MoveTo((root.Parent["Right Arm"].CFrame*CFrame.new((reach/2),0,0)).Position)
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- end
- end
- else
- if mag<=reach then
- print("player coming from top at "..top)
- local frame = CFrame.new(sword.Handle.Position,(root.Parent["Left Arm"].CFrame*CFrame.new(0,0,0)).Position)
- gyro.CFrame = frame
- char.Humanoid:MoveTo((root.CFrame*CFrame.new(2,0,-(reach/2))).Position)
- repeat
- wait()
- local ragg = root.CFrame:ToObjectSpace(rootC.CFrame)
- if sword:FindFirstChild("Handle") then
- local frame = CFrame.new(sword.Handle.Position,root.CFrame.Position)
- end
- gyro.CFrame = frame
- char.Humanoid:MoveTo((root.CFrame*CFrame.new(-2,0,-2)).Position)
- until rag.Position.Y>=-6
- print("under")
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- end
- end
- else
- if face>0 then
- print("coming from behind")
- local framer2 = CFrame.new(rootC.Position,root.Position)
- gyro.CFrame = framer2
- local hum = char.Humanoid
- hum:MoveTo((root.CFrame*CFrame.new(2,0,(reach/2))).Position)
- if mag<=reach then
- for i = 1,2 do
- wait()
- sword:Activate()
- end
- end
- end
- end
- end
- end
- end
- end
- end
- function findNearest()
- local dist = distance
- local root
- local all = parent:GetChildren()
- local chars = {}
- local mag
- local rooter
- if #all>0 then
- for i= 1,#all do
- local hum = all[i]:FindFirstChildOfClass("Humanoid")
- if hum~=nil and hum.Health>0 then
- if all[i].Parent~=script.Parent then
- root = all[i]:FindFirstChild("HumanoidRootPart")
- if root then
- mag = (root.Position-rootC.Position).Magnitude
- if mag<= dist then
- if root~=rootC then
- table.insert(chars,#chars+1,mag)
- end
- end
- end
- end
- end
- end
- table.sort(chars)
- if #chars>0 then
- for i= 1,#all do
- local hum = all[i]:FindFirstChildOfClass("Humanoid")
- if hum~=nil then
- if all[i].Parent~=char then
- root = all[i]:FindFirstChild("HumanoidRootPart")
- if root then
- mag = (root.Position-rootC.Position).Magnitude
- if mag == chars[1] then
- rooter = root
- end
- end
- end
- end
- end
- end
- end
- return rooter
- end
- local lastHealth = char.Humanoid.Health
- function autoFight(dista)
- char = game.Players.LocalPlayer.Character
- distance = dista
- local swo
- local all = char:GetChildren()
- local sword
- for _,v in pairs(all) do
- if v.ClassName == "Tool" then
- sword = v
- end
- end
- if not sword then
- local all = game.Players.LocalPlayer.Backpack:GetChildren()
- repeat wait() all = game.Players.LocalPlayer.Backpack:GetChildren() until #all>0
- if all[1].ClassName == "Tool" then
- all[1].Parent = char
- sword = all[1]
- end
- end
- auto = true
- local run
- gyro.MaxTorque = Vector3.new(0,math.huge,0)
- while wait(((10-difficulty)/10)) do
- local new = char.Humanoid.Health
- if new~=lastHealth then
- onHealthChanged(new)
- end
- lastHealth = char.Humanoid.Health
- game.Players.LocalPlayer.Chatted:Connect(function(mes)
- if string.lower(mes) == "/e stop" then
- auto = false
- end
- end)
- if auto == true then
- local root = findNearest()
- if root then
- if char:FindFirstChild("Humanoid")~=nil then
- attack(root.Parent,sword)
- end
- else
- end
- else
- gyro.MaxTorque = Vector3.new(0,0,0)
- break
- end
- end
- end
- game.Players.LocalPlayer.Chatted:Connect(function(mes)
- if string.sub(mes,1,8) == "/e auto " then
- if auto == false then
- print("going auto")
- autoFight(tonumber(string.sub(mes,9,#mes)))
- end
- else
- if string.sub(mes,1,7) == "/e dif " then
- print("set difficulty to "..string.sub(mes,8,#mes))
- difficulty = tonumber(string.sub(mes,8,#mes))
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement