Advertisement
SpacecowboyHX

Untitled

Aug 31st, 2020
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.24 KB | None | 0 0
  1.  
  2. local parent = workspace.CurrentCamera
  3. local char = game.Players.LocalPlayer.Character
  4. repeat wait() char= game.Players.LocalPlayer.Character until char
  5. wait(1)
  6. char.Archivable = true
  7. local rootC = char.HumanoidRootPart
  8. local distance = 20
  9. local reach = 6
  10. local gyro = Instance.new("BodyGyro",rootC)
  11. gyro.MaxTorque = Vector3.new(0,math.huge,0)
  12. gyro.MaxTorque = Vector3.new(0,0,0)
  13. gyro.P = 10000
  14. gyro.D = 0
  15. local difficulty = 10
  16. local died = false
  17. local jumped = false
  18. local auto = false
  19. function run(charr)
  20. local find = charr:FindFirstChild("HumanoidRootPart")
  21. if find then
  22. local char = game.Players.LocalPlayer.Character
  23. local frame = CFrame.new(find.Position,char.HumanoidRootPart.Position)*CFrame.new(0,0,-distance+10)
  24. local pos = frame.Position
  25. char.Humanoid:MoveTo(pos)
  26. end
  27. end
  28. function onHealthChanged(health)
  29. if health == 0 and died == false then died = true
  30. warn("DIED")
  31. wait(game.Players.RespawnTime+.3)
  32. char= game.Players.LocalPlayer.Character
  33. repeat wait() char= game.Players.LocalPlayer.Character until char
  34. wait(.3)
  35. char.Archivable = true
  36. rootC = char.HumanoidRootPart
  37. reach = 7
  38. gyro= Instance.new("BodyGyro",rootC)
  39. gyro.MaxTorque = Vector3.new(0,0,0)
  40. gyro.P = 999999999999
  41. gyro.D = 0
  42. jumped = false
  43. local save = auto
  44. auto = false
  45. wait()
  46. if save == true then
  47. autoFight(distance)
  48. end
  49. died = false
  50. end
  51. end
  52. function attack(char2,sword)
  53. char = game.Players.LocalPlayer.Character
  54. if sword and sword.Parent == char and char:FindFirstChild("Humanoid")~=nil then
  55. --attacker is char2
  56. local root = char2:FindFirstChild("HumanoidRootPart")
  57. if root then
  58. if char2.Humanoid.Health>0 and char.Humanoid.Health>0 then
  59. local mag = (rootC.Position-root.Position).Magnitude
  60. local rag = root.CFrame:ToObjectSpace(rootC.CFrame)
  61. local rag2 = rootC.CFrame:ToObjectSpace(root.CFrame)
  62. local side = rag.Position.X
  63. local face = rag.Position.Z
  64. local top = rag.Position.Y
  65. --front face is in negative
  66. --side negative is left
  67. local convS = tostring(side)
  68. local convF = tostring(face)
  69. local findS = string.sub(convS,1,1)
  70. local findF = string.sub(convF,1,1)
  71. if rootC.Velocity.Magnitude >100 then
  72. print("velocity is too high")
  73. rootC.Velocity = Vector3.new(0,0,0)
  74. end
  75. if side<0 then
  76. if mag<=reach/2 then
  77. local rando = math.random(1,100)
  78. if rando == 100 then
  79. if jumped == false then jumped = true
  80. char.Humanoid.Jump = true
  81. jumped = false
  82. end
  83. end
  84. jumped = false
  85. local frame = CFrame.new(sword.Handle.Position,root.Parent["Left Arm"].Position)
  86. local mag2 = (rootC.Position-root.Parent["Left Arm"].Position).Magnitude
  87. local mag3 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
  88. if mag2<=reach/2 then
  89. jumped = false
  90. local framer = root.CFrame*CFrame.new(-2,0,-reach)
  91. if mag3<=reach/2 then
  92. print("may die")
  93. if jumped == false then jumped = true
  94. char.Humanoid.Jump = true
  95. jumped = false
  96. end
  97. local hum = char.Humanoid
  98. hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach*2))).Position)
  99. else
  100. local hum = char.Humanoid
  101. hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach))).Position)
  102. end
  103. gyro.CFrame = frame
  104. for i = 1,2 do
  105. wait()
  106. sword:Activate()
  107. end
  108. else
  109. print("very close")
  110. jumped = false
  111. gyro.CFrame = frame
  112. frame = CFrame.new(sword.Handle.Position,root.Parent["Left Arm"].Position)
  113. for i = 1,2 do
  114. wait()
  115. sword:Activate()
  116. end
  117. end
  118. else
  119. if mag<=reach then
  120. local mag2 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
  121. --[[if char2.Humanoid.Jump == true then
  122. char.Humanoid.Jump = true
  123. local framer = root.CFrame*CFrame.new(0,0,-2)
  124. local frame = CFrame.new(sword.Handle.Position,root.Position)
  125. gyro.CFrame = frame
  126. char.Humanoid:MoveTo((root.CFrame*CFrame.new(0,0,-reach)).Position)
  127. end]]
  128. if mag2<=reach then
  129. print("left arm vunerable")
  130. if jumped == false then jumped = true
  131. char.Humanoid.Jump = true
  132. jumped = false
  133. end
  134. local frame = CFrame.new(sword.Handle.Position,root.Position)
  135. gyro.CFrame = frame
  136. local framer = root.CFrame*CFrame.new(0,0,-reach)
  137. char.Humanoid:MoveTo(framer.Position)
  138. else
  139. print("within reach")
  140. local mag2 = (rootC.Position-root.Parent["Right Arm"].Position).Magnitude
  141. for i = 1,2 do
  142. wait()
  143. sword:Activate()
  144. end
  145. local framer = root.CFrame*CFrame.new(0,0,-2)
  146. local frame = CFrame.new(sword.Handle.Position,root.Position)
  147. gyro.CFrame = frame
  148. framer = root.CFrame*CFrame.new(-4,0,-2)
  149. char.Humanoid:MoveTo(framer.Position)
  150. end
  151. else
  152. if mag<=reach*2 then
  153. jumped = false
  154. local mag2 = (rootC.Parent["Left Arm"].Position-root.Parent["Right Arm"].Position).Magnitude
  155. if mag2<=reach+((reach*2)/3) and rag2.Position.Y<=0 then
  156. print("left arm Semi-close")
  157. if jumped == false then jumped = true
  158. char.Humanoid.Jump = true
  159. end
  160. jumped = false
  161. local framer = root.CFrame*CFrame.new(0,0,-reach)
  162. char.Humanoid:MoveTo(framer.Position)
  163. local frame = CFrame.new(sword.Handle.Position,(root.Parent["Right Arm"].CFrame*CFrame.new(2,0,0)).Position)
  164. gyro.CFrame = frame
  165. for i = 1,2 do
  166. wait()
  167. sword:Activate()
  168. end
  169. local hum = char.Humanoid
  170. hum:MoveTo((root.CFrame*CFrame.new(-4,0,-(reach*2))).Position)
  171. else
  172. print("approching")
  173. jumped = false
  174. local frame = CFrame.new(rootC.Position,root.Parent["Right Arm"].Position)
  175. local framer2 = CFrame.new(rootC.Position)*CFrame.Angles(0,math.rad(root.Orientation.Y)+math.pi,0)
  176. gyro.CFrame = framer2
  177. local hum = char.Humanoid
  178. for i = 1,2 do
  179. wait()
  180. sword:Activate()
  181. end
  182. hum:MoveTo((root.CFrame*CFrame.new(0,0,-(reach))).Position)
  183. end
  184. else
  185. print("far away")
  186. jumped = false
  187. local frame = CFrame.new(rootC.Position,root.Parent["Right Arm"].Position)
  188. gyro.CFrame = frame
  189. char.Humanoid:MoveTo(root.Position)
  190. end
  191. end
  192. end
  193. else
  194. if face<=0 then
  195. if top>-7 then
  196. if side<4 then
  197. jumped = false
  198. local frame = CFrame.new(sword.Handle.Position,(root.Parent["Right Arm"].CFrame*CFrame.new(0,0,-1)).Position)
  199. local framer2 = CFrame.new(rootC.Position)*CFrame.Angles(0,math.rad(root.Orientation.Y)+math.pi,0)
  200. if mag<=reach*2 then
  201. print("coming close")
  202. gyro.CFrame = frame
  203. local hum = char.Humanoid
  204. hum:MoveTo((root.CFrame*CFrame.new(1,0,-(reach))).Position)
  205. for i = 1,2 do
  206. wait()
  207. sword:Activate()
  208. end
  209. else
  210. print("on wrong side")
  211. gyro.CFrame = frame
  212. local hum = char.Humanoid
  213. hum:MoveTo((root.CFrame*CFrame.new(-2,0,-(reach*2))).Position)
  214. end
  215. else
  216. if side>= 4 then
  217. print("coming from arm")
  218. local frame = CFrame.new(sword.Handle.Position,root.Parent["Right Arm"].Position)
  219. gyro.CFrame = frame
  220. local hum = char.Humanoid
  221. hum:MoveTo((root.Parent["Right Arm"].CFrame*CFrame.new((reach/2),0,0)).Position)
  222. for i = 1,2 do
  223. wait()
  224. sword:Activate()
  225. end
  226. end
  227. end
  228. else
  229. if mag<=reach then
  230. print("player coming from top at "..top)
  231. local frame = CFrame.new(sword.Handle.Position,(root.Parent["Left Arm"].CFrame*CFrame.new(0,0,0)).Position)
  232. gyro.CFrame = frame
  233. char.Humanoid:MoveTo((root.CFrame*CFrame.new(2,0,-(reach/2))).Position)
  234. repeat
  235. wait()
  236. local ragg = root.CFrame:ToObjectSpace(rootC.CFrame)
  237. if sword:FindFirstChild("Handle") then
  238. local frame = CFrame.new(sword.Handle.Position,root.CFrame.Position)
  239. end
  240. gyro.CFrame = frame
  241. char.Humanoid:MoveTo((root.CFrame*CFrame.new(-2,0,-2)).Position)
  242. until rag.Position.Y>=-6
  243. print("under")
  244. for i = 1,2 do
  245. wait()
  246. sword:Activate()
  247. end
  248. end
  249. end
  250. else
  251. if face>0 then
  252. print("coming from behind")
  253. local framer2 = CFrame.new(rootC.Position,root.Position)
  254. gyro.CFrame = framer2
  255. local hum = char.Humanoid
  256. hum:MoveTo((root.CFrame*CFrame.new(2,0,(reach/2))).Position)
  257. if mag<=reach then
  258. for i = 1,2 do
  259. wait()
  260. sword:Activate()
  261. end
  262. end
  263. end
  264. end
  265. end
  266. end
  267. end
  268. end
  269. end
  270. function findNearest()
  271. local dist = distance
  272. local root
  273. local all = parent:GetChildren()
  274. local chars = {}
  275. local mag
  276. local rooter
  277. if #all>0 then
  278. for i= 1,#all do
  279. local hum = all[i]:FindFirstChildOfClass("Humanoid")
  280. if hum~=nil and hum.Health>0 then
  281. if all[i].Parent~=script.Parent then
  282. root = all[i]:FindFirstChild("HumanoidRootPart")
  283. if root then
  284. mag = (root.Position-rootC.Position).Magnitude
  285. if mag<= dist then
  286. if root~=rootC then
  287. table.insert(chars,#chars+1,mag)
  288. end
  289. end
  290. end
  291. end
  292. end
  293. end
  294. table.sort(chars)
  295. if #chars>0 then
  296. for i= 1,#all do
  297. local hum = all[i]:FindFirstChildOfClass("Humanoid")
  298. if hum~=nil then
  299. if all[i].Parent~=char then
  300. root = all[i]:FindFirstChild("HumanoidRootPart")
  301. if root then
  302. mag = (root.Position-rootC.Position).Magnitude
  303. if mag == chars[1] then
  304. rooter = root
  305. end
  306. end
  307. end
  308. end
  309. end
  310. end
  311. end
  312. return rooter
  313. end
  314. local lastHealth = char.Humanoid.Health
  315. function autoFight(dista)
  316. char = game.Players.LocalPlayer.Character
  317. distance = dista
  318. local swo
  319. local all = char:GetChildren()
  320. local sword
  321. for _,v in pairs(all) do
  322. if v.ClassName == "Tool" then
  323. sword = v
  324. end
  325. end
  326. if not sword then
  327. local all = game.Players.LocalPlayer.Backpack:GetChildren()
  328. repeat wait() all = game.Players.LocalPlayer.Backpack:GetChildren() until #all>0
  329. if all[1].ClassName == "Tool" then
  330. all[1].Parent = char
  331. sword = all[1]
  332. end
  333. end
  334. auto = true
  335. local run
  336. gyro.MaxTorque = Vector3.new(0,math.huge,0)
  337. while wait(((10-difficulty)/10)) do
  338. local new = char.Humanoid.Health
  339. if new~=lastHealth then
  340. onHealthChanged(new)
  341. end
  342. lastHealth = char.Humanoid.Health
  343. game.Players.LocalPlayer.Chatted:Connect(function(mes)
  344. if string.lower(mes) == "/e stop" then
  345. auto = false
  346. end
  347. end)
  348. if auto == true then
  349. local root = findNearest()
  350. if root then
  351. if char:FindFirstChild("Humanoid")~=nil then
  352. attack(root.Parent,sword)
  353. end
  354. else
  355. end
  356. else
  357. gyro.MaxTorque = Vector3.new(0,0,0)
  358. break
  359. end
  360. end
  361. end
  362. game.Players.LocalPlayer.Chatted:Connect(function(mes)
  363. if string.sub(mes,1,8) == "/e auto " then
  364. if auto == false then
  365. print("going auto")
  366. autoFight(tonumber(string.sub(mes,9,#mes)))
  367. end
  368. else
  369. if string.sub(mes,1,7) == "/e dif " then
  370. print("set difficulty to "..string.sub(mes,8,#mes))
  371. difficulty = tonumber(string.sub(mes,8,#mes))
  372. end
  373. end
  374. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement