View difference between Paste ID: 6BwC2eA2 and 6FUWKeP7
SHOW: | | - or go back to the newest paste.
1
--[[
2
/////////AutoFight///////
3
////Made by Indencito////
4
]]
5
local lp = game.Players.LocalPlayer
6
local players = game.Players:GetChildren()
7-
local availPlayers = {}
7+
local availPlayers = {Ninja_tron9000}
8-
local currentOuts = {}
8+
local currentOuts = {Ninja_tron9000}
9
local outlined = false
10
local cam = workspace.CurrentCamera
11
local db = false
12
local gotoRefresh = 0.5
13-
local pf = false
13+
14
	["AgentHeight"] = 5;
15
	["AgentRaduis"] = 7;
16
	["AgentCanJump"] = true
17
}
18
function Goto(player,pos)
19
	local char
20
	if player~=nil then
21
		char = player.Character
22
	end
23
	local hum
24
	if char then
25
		hum = char:FindFirstChild("Humanoid")
26
	end
27
	if char and hum then
28
		local parts = {}
29
		local health = hum.Health
30
		local paths = game:GetService("PathfindingService")
31
		local path = paths:CreatePath(params)
32
		local health2 = lp.Character.Humanoid.Health
33
		if health>0 and health2>0 then
34
			path:ComputeAsync(char.PrimaryPart.Position,(lp.Character.PrimaryPart.CFrame*CFrame.new(0,0,-7.5)).Position)
35
			local points = path:GetWaypoints()
36
			for i=1,#points do
37
				local new = Instance.new("Part")
38
				new.Material = Enum.Material.Neon
39
				new.Transparency = 0.5
40
				new.Color = Color3.new(255,0,0)
41
				table.insert(parts,i,new)
42
				new.Anchored = true
43
				new.CanCollide = false
44
				new.Parent = workspace
45
				if i>1 then
46
					local mag = (points[i-1].Position-points[i].Position).Magnitude
47
					new.CFrame = CFrame.new(points[i-1].Position,points[i].Position)*CFrame.new(0,0,-mag/2)
48
					new.Size = Vector3.new(1,1,mag)
49
				end
50
			end
51
			if #points>0 then
52
				for i = 1,#points do
53
					local i = #points-(i-1)
54
					if health>0 and health2>0 then
55
						if path.Status == Enum.PathStatus.Success then
56
							lp.Character.Humanoid:MoveTo(points[i].Position)
57
							if points[i].Action == Enum.PathWaypointAction.Jump then
58
								lp.Character.Humanoid.Jump = true
59
							end
60
							lp.Character.Humanoid.MoveToFinished:Wait()
61
							if i == 1 then
62
								for i = 1,#parts do
63
									parts[i]:Destroy()
64
								end
65
								parts = {}
66
								db = true
67
							end
68
						else
69
							break
70
						end
71
					else
72
						break
73
					end
74
				end
75
			end
76
		end
77
	else
78
		if pos and not hum then
79
			local parts = {}
80
			local timer = tick()
81
			local paths = game:GetService("PathfindingService")
82
			local path = paths:CreatePath(params)
83
			local health2 = lp.Character.Humanoid.Health
84
			if health2>0 then
85
				path:ComputeAsync(pos,(lp.Character.PrimaryPart.CFrame*CFrame.new(0,0,-7.5)).Position)
86
				local points = path:GetWaypoints()
87
				for i=1,#points do
88
					local new = Instance.new("Part")
89
					new.Material = Enum.Material.Neon
90
					new.Transparency = 0.5
91
					new.BrickColor = BrickColor.new("Really red")
92
					table.insert(parts,i,new)
93
					new.Anchored = true
94
					new.CanCollide = false
95
					new.Parent = workspace
96
					if i>1 then
97
						local mag = (points[i-1].Position-points[i].Position).Magnitude
98
						new.CFrame = CFrame.new(points[i-1].Position,points[i].Position)*CFrame.new(0,0,-mag/2)
99
						new.Size = Vector3.new(0.5,0.5,mag)
100
					end
101
				end
102
				if #points>0 then
103
					for i = 1,#points do
104
						local i = #points-(i-1)
105
						if health2>0 then
106
							if path.Status == Enum.PathStatus.Success then
107
								if tick()-timer<gotoRefresh then
108
									lp.Character.Humanoid:MoveTo(points[i].Position)
109-
									local ray = Ray.new(lp.Character.PrimaryPart.Position,(lp.Character.PrimaryPart.Position-pos))
109+
									if points[i].Action == Enum.PathWaypointAction.Jump then
110-
									local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{lp.Character})
110+
										lp.Character.Humanoid.Jump = true
111-
									if hit then
111+
112-
										lp.Character.Humanoid:MoveTo(points[i].Position)
112+
									lp.Character.Humanoid.MoveToFinished:Wait()
113-
										if points[i].Action == Enum.PathWaypointAction.Jump then
113+
									if i == 1 then
114-
											lp.Character.Humanoid.Jump = true
114+
										for i = 1,#parts do
115
											parts[i]:Destroy()
116-
										lp.Character.Humanoid.MoveToFinished:Wait()
116+
117-
										if i == 1 then
117+
										parts = {}
118-
											for i = 1,#parts do
118+
119-
												parts[i]:Destroy()
119+
120-
											end
120+
121-
											parts = {}
121+
122
										parts[i]:Destroy()
123-
									else
123+
124-
										pf = false
124+
125-
										break
125+
126
								end
127
							else
128
								break
129
							end
130
						else
131
							break
132
						end
133
					end
134
				end
135
			end
136
		end
137
	end
138
end
139
function chat(string)
140
	game:service("Chat"):Chat(lp.Character.Head, string, Enum.ChatColor.White)
141
end
142
function auto(dist)
143
	while wait() do
144
		local function FindTorso(dist)
145
			local pos = lp.Character:FindFirstChild("HumanoidRootPart").Position
146
			local list = game.Players:GetChildren()
147
			local root = nil 
148-
	local Event = game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest
148+
149-
	Event:FireServer(string) 
149+
150
			local temp2 = nil
151
			for x = 1, #list do
152
				temp2 = list[x]
153
				if (temp2.className == "Player") and (temp2 ~= lp) then
154
					temp2 = temp2.Character
155
					temp = temp2:findFirstChild("HumanoidRootPart")
156
					human = temp2:findFirstChild("Humanoid")
157
					if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
158
						if (temp.Position - pos).magnitude < dist then
159
							root = temp
160
							dist = (temp.Position - pos).magnitude
161
						end
162
					end
163
				end
164
			end
165
			return root
166
		end
167
		if db == true then
168
			local root = FindTorso(dist)
169
			if root then
170
				local find = game.Players:FindFirstChild(root.Parent.Name)
171
				if find then
172
					local ray = Ray.new(lp.Character.PrimaryPart.Position,root.Position)
173
					local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{lp.Character})
174
					if not hit then
175
						target(find)
176
					else
177
						if hit.CanCollide == true then
178
							db = false
179
							Goto(find)
180
							repeat until db == true
181-
					local ray = Ray.new(lp.Character.PrimaryPart.Position,(lp.Character.PrimaryPart.Position-root.Position))
181+
182
						else
183
							target(find)
184
						end
185
					end
186
				end
187
			end
188
		else
189
			break
190
		end
191
	end
192
end
193
function target(player)
194
	if player~=nil then
195
		local tool = nil
196
		local hum = lp.Character:WaitForChild("Humanoid")
197
		local hum2 = player.Character:WaitForChild("Humanoid")
198
		local root1 = lp.Character:WaitForChild("HumanoidRootPart")
199
		local root2 = player.Character:WaitForChild("HumanoidRootPart")
200
		while wait() do
201
			repeat until hum ~=nil and hum2 ~=nil
202
			local verify = player.Character:FindFirstChild("Humanoid").Health
203
			local verify2 = lp.Character:FindFirstChild("Humanoid").Health
204
			if verify>0 then
205
				if verify2>0 then
206
					if db == true then
207
						local mag = (root1.Position-root2.Position).Magnitude
208
						if hum2.Jump==true then
209-
		local chatted = false
209+
							hum.Jump = true
210
						end
211
						if mag<=15 then
212-
			local v1 = lp.Character
212+
							local tools = lp.Backpack:GetChildren()
213-
			local v2 = lp.Character
213+
							if #tools>0 then
214
								tool = tools[1]
215
								tool.Parent = lp.Character
216-
			if v1 and v2 then
216+
								tool:Activate()
217-
				if verify>0 then
217+
218-
					if verify2>0 then
218+
								if tool~=nil then
219-
						if db == true then
219+
									if tool.ClassName=="Tool" then
220
										tool:Activate()
221-
							if hum2.Jump==true then
221+
222-
								hum.Jump = true
222+
223
							end
224-
							if mag<=15 then
224+
							local frame = root2.CFrame*CFrame.new(-3,0,0)
225-
								local tools = lp.Backpack:GetChildren()
225+
226-
								if #tools>0 then
226+
							local ray = Ray.new(root1.Position,frame.Position)
227-
									tool = tools[1]
227+
							local hit,position = workspace:FindPartOnRayWithIgnoreList(ray,{lp.Character})
228-
									tool.Parent = lp.Character
228+
							if hit==nil then
229-
									tool:Activate()
229+
								local extraframe = root2.CFrame*CFrame.new(2,0,0)
230
								cam.CFrame = CFrame.new(cam.CFrame.Position,extraframe.Position)
231-
									if tool~=nil then
231+
								Goto(nil,frame.Position)--test
232-
										if tool.ClassName=="Tool" then
232+
233-
											tool:Activate()
233+
								if hit~=nil then
234
									local extraframe = root2.CFrame*CFrame.new(2,0,0)
235
									cam.CFrame = CFrame.new(cam.CFrame.Position,extraframe.Position)
236
								end
237
								local frame = root2.CFrame*CFrame.new(-3,0,0)
238-
								local mag = (root1.Position-root2.Position).Magnitude
238+
								Goto(nil,frame.Position)--test
239-
								local ray = Ray.new(root1.Position,(root1.Position-player.Character.HumanoidRootPart.Position))
239+
240-
								local hit,position = workspace:FindPartOnRayWithIgnoreList(ray,{lp.Character})
240+
241
							local frame = root2.CFrame*CFrame.new(0,0,-7.5)
242-
									local frame = root2.CFrame*CFrame.new(-3,0,0)
242+
							local extraframe = root2.CFrame*CFrame.new(-2,0,0)
243
							cam.CFrame = CFrame.new(cam.CFrame.Position,extraframe.Position)
244
							Goto(nil,frame.Position)--test
245-
									hum:MoveTo(frame.Position)
245+
246
					else
247-
									if hit then
247+
248-
										local extraframe = root2.CFrame*CFrame.new(2,0,0)
248+
249-
										cam.CFrame = CFrame.new(cam.CFrame.Position,extraframe.Position)
249+
250-
										local frame = root2.CFrame*CFrame.new(-3,0,0)
250+
					print("failed to pwn "..player.Name..". sorry!")
251-
										print("hit "..hit.Name)
251+
					availPlayers = {}
252-
										Goto(nil,frame.Position)--test
252+
					if #currentOuts>0 then
253
						for i = 1,#currentOuts do
254
							if currentOuts[i]~=nil then
255
								currentOuts[i]:Destroy()
256-
								local frame = root2.CFrame*CFrame.new(0,0,-7.5)
256+
257-
								local extraframe = root2.CFrame*CFrame.new(-2,0,0)
257+
258-
								local ray = Ray.new(lp.Character.PrimaryPart.Position,(lp.Character.PrimaryPart.Position-player.Character.PrimaryPart.Position))
258+
259
					end
260
					for i = 1,#availPlayers do
261-
								if hit then
261+
						table.remove(availPlayers,i)
262-
									print("hit")
262+
263-
									Goto(nil,frame.Position)--test
263+
					outlined=false
264
					break
265-
									if not hit then
265+
266-
										hum:MoveTo(frame.Position)
266+
267
				chat(player.Name.." is a noob")
268
				if tool~=nil then
269
					tool.Parent = lp.Backpack
270
				end
271
				for i = 1,#currentOuts do
272
					if currentOuts[i].Parent.Parent == player.Character then
273
						table.remove(currentOuts,i)
274-
						availPlayers = {}
274+
275-
						if #currentOuts>0 then
275+
276-
							for i = 1,#currentOuts do
276+
				for i = 1,#availPlayers do
277-
								if currentOuts[i]~=nil then
277+
					if availPlayers[i]==player.Name then
278-
									currentOuts[i]:Destroy()
278+
						table.remove(availPlayers,i)
279
					end
280-
								table.remove(currentOuts,i)
280+
281
				break
282
			end
283-
						for i = 1,#availPlayers do
283+
284-
							table.remove(availPlayers,i)
284+
285
end
286-
						outlined=false
286+
287
	outlined = true
288
	local players = game.Players:GetChildren()
289
	for i = 1,#players do
290-
					if chatted == false then chatted = true
290+
291-
						chat(player.Name.." is a noob")
291+
292
		local outline = Instance.new("SelectionBox")
293-
					if tool~=nil then
293+
294-
						tool.Parent = lp.Backpack
294+
295
		outline.SurfaceColor3 = Color3.new(172,0,0)
296-
					for i = 1,#currentOuts do
296+
297-
						if currentOuts[i].Parent.Parent == player.Character then
297+
298
		local root = char:FindFirstChild("HumanoidRootPart")
299
		if (root~=nil) then
300
			outline.Parent = root
301
			outline.Adornee = root
302-
						if availPlayers[i]==player.Name then
302+
303-
							table.remove(availPlayers,i)
303+
304
		else
305
			outline:Destroy()
306
		end
307
	end
308
end
309
local mouse = lp:GetMouse()
310
mouse.Button1Down:Connect(function()
311
	local pos = mouse.Hit.p
312
	local target = mouse.Target
313
	if target.Parent:FindFirstChild("Humanoid")~=nil then
314
		local find = game.Players:FindFirstChild(target.Parent.Name)
315
		if (find~=nil) then
316
			if outlined == true then
317
				for o = 1,#availPlayers do
318
					if availPlayers[o].Name==find.Name then
319
						target(find)
320
						print("yes")
321
					end
322
				end
323
			else
324
				print("no outlined players")
325
			end
326
		end
327
	end
328
end)
329
lp.Chatted:Connect(function(msg)
330
	local text1 = ""
331
	local text2 = ""
332
	if string.lower(msg)=="/e outline" then
333
		local players = game.Players:GetChildren()
334
		if #currentOuts>0 then
335
			for i = 1,#currentOuts do
336
				if currentOuts[i]~=nil then
337
					currentOuts[i]:Destroy()
338
				end
339
				table.remove(currentOuts,i)
340
			end
341-
	if target then
341+
342-
		if target.Parent:FindFirstChild("Humanoid")~=nil then
342+
343-
			local find = game.Players:FindFirstChild(target.Parent.Name)
343+
344-
			if (find~=nil) then
344+
345-
				if outlined == true then
345+
346-
					for o = 1,#availPlayers do
346+
347-
						if availPlayers[o].Name==find.Name then
347+
348
		for i = 1,#players do
349-
							print("yes")
349+
350
		end
351
		local text2 = "[Autofight]: The player list is "..text1
352
		--////////////
353-
					print("no outlined players")
353+
354
			Text = text2..[[. The command for a specific player is "/e target PLAYER", you can use abbreviation as well.]];
355
			Color = Color3.new(0,175,0);
356
			Font = Enum.Font.SourceSansBold;
357
			FontSize = Enum.FontSize.Size18;
358-
		warn("no target selected")
358+
359
		--////////////
360
	else
361
		local msg = string.lower(msg)
362
		if string.sub(msg,1,10)=="/e target " then
363
			local players = game.Players:GetChildren()
364
			if outlined == true then
365
				local name = string.lower(string.sub(msg,11,#msg))
366
				for i = 1,#players do
367
					local name2 = string.lower(players[i].Name)
368
					if string.sub(name2,1,#name)==name then
369
						for o = 1,#availPlayers do
370
							wait()
371
							if availPlayers[o].Name==players[i].Name then
372
								local ray = Ray.new(lp.Character.PrimaryPart.Position,players[i].Character.PrimaryPart.Position)
373
								local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{lp.Character})
374
								if not hit then
375
									game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
376
										Text = "[Autofight]: Now targeting "..players[i].Name..". make sure Shift Lock is on and dont move.";
377
										Color = Color3.new(0,128,128);
378
										Font = Enum.Font.SourceSansBold;
379
										FontSize = Enum.FontSize.Size18;
380
									})
381
									db = true
382
									target(players[i])
383
								else
384
									game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
385
										Text = "[Autofight]: Now targeting "..players[i].Name..". make sure Shift Lock is on and dont move.";
386
										Color = Color3.new(0,128,128);
387
										Font = Enum.Font.SourceSansBold;
388
										FontSize = Enum.FontSize.Size18;
389
									})
390
									db = false
391
									Goto(players[i])
392
									repeat until db == true
393
									target(players[i])
394
								end
395
							end
396
						end
397
					end
398
				end
399
			else
400
				game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
401
					Text = "[Autofight]: No players outlined, use /e outline command to begin...";
402
					Color = Color3.new(255,0,0);
403
					Font = Enum.Font.SourceSansBold;
404-
								local ray = Ray.new(lp.Character.PrimaryPart.Position,(lp.Character.PrimaryPart.Position-players[i].Character.PrimaryPart.Position))
404+
405
				})
406
			end
407
		else
408
			if string.lower(msg) == "/e stop" then
409
				if db == true then db = false
410
				else
411
					print("Not targeting anyone")
412
                                                                                                   print("AutoFight made by Indencito")
413
				end
414
			else
415
				local msg = string.lower(msg)
416
				if string.sub(msg,1,7) == "/e auto" then
417
					if string.sub(msg,9,#msg)~=nil then
418
						local dist = tonumber(string.sub(msg,9,#msg))
419
						if db == true then db = false end
420
						db = true
421
						auto(dist)
422
					end
423
				end
424
			end
425
		end
426
	end
427
end)