View difference between Paste ID: CnVCA6yY and 2jqdRSiE
SHOW: | | - or go back to the newest paste.
1
local plrs = game:GetService("Players")
2
local TeamBased = true ; local teambasedswitch = "o"
3
local presskeytoaim = true; local aimkey = "e"
4
local raycast = false
5
 
6
local espupdatetime = 5; autoesp = false
7
 
8
 
9
 
10
local lockaim = true; local lockangle = 5
11
 
12
 
13
 
14
--function findwat(folder, what)
15
--  for i, smth in pairs(folder:GetChildren()) do
16
--      if string.find(string.lower(tostring(smth)), string.lower(what)) then
17
--          return smth
18
--      end
19
--  end
20
--end
21
--
22
--local plrs = findwat(game, "Players")
23
 
24
 
25
 
26
 
27
local Gui = Instance.new("ScreenGui")
28
local Move = Instance.new("Frame")
29
local Main = Instance.new("Frame")
30
local EspStatus = Instance.new("TextLabel")
31
local st1 = Instance.new("TextLabel")
32
local st1_2 = Instance.new("TextLabel")
33
local st1_3 = Instance.new("TextLabel")
34
local Name = Instance.new("TextLabel")
35
36
-- Scripts:
37
 
38
 
39
local plrsforaim = {}
40
 
41
local lplr = game:GetService("Players").LocalPlayer
42
Move.Draggable = true
43
Gui.ResetOnSpawn = false
44
Gui.Name = "Chat"
45
Gui.DisplayOrder = 999
46
 
47
    Gui.Parent = plrs.LocalPlayer.PlayerGui
48
 
49
 
50
f = {}
51
local espforlder
52
 
53
f.addesp = function()
54
    --print("ESP ran")
55
    if espforlder then
56
    else
57
        espforlder = Instance.new("Folder")
58
        espforlder.Parent = game.Workspace.CurrentCamera
59
    end
60
    for i, v in pairs(espforlder:GetChildren()) do
61
        v:Destroy()
62
    end
63
    for _, plr in pairs(plrs:GetChildren()) do
64
        if plr.Character and plr.Character.Humanoid.Health > 0 and plr.Name ~= lplr.Name then
65
            if TeamBased == true then
66
                if plr.Team.Name ~= plrs.LocalPlayer.Team.Name  then
67
                    local e = espforlder:FindFirstChild(plr.Name)
68
                    if not e then
69
                        --print("Added esp for team based")
70
                        local bill = Instance.new("BillboardGui", espforlder)
71
                        bill.Name = plr.Name
72
                        bill.AlwaysOnTop = true
73
                        bill.Size = UDim2.new(1,0,1,0)
74
                        bill.Adornee = plr.Character.Head
75
                        local Frame = Instance.new('Frame',bill)
76
                        Frame.Active = true
77
                        Frame.BackgroundColor3 = Color3.new(0/255,255/255,0/255)
78
                        Frame.BackgroundTransparency = 0
79
                        Frame.BorderSizePixel = 0
80
                        Frame.AnchorPoint = Vector2.new(.5, .5)
81
                        Frame.Position = UDim2.new (0.5,0,0.5,0)
82
                        Frame.Size = UDim2.new (1,0,1,0)
83
                        Frame.Rotation = 0
84
                        plr.Character.Humanoid.Died:Connect(function()
85
                            bill:Destroy()
86
                        end)
87
                    end
88
                end
89
            else
90
                local e = espforlder:FindFirstChild(plr.Name)
91
                if not e then
92
                    --print("Added esp")
93
                    local bill = Instance.new("BillboardGui", espforlder)
94
                    bill.Name = plr.Name
95
                    bill.AlwaysOnTop = true
96
                    bill.Size = UDim2.new(1,0,1,0)
97
                    bill.Adornee = plr.Character.Head
98
                    local Frame = Instance.new('Frame',bill)
99
                    Frame.Active = true
100
                    Frame.BackgroundColor3 = Color3.new(0/255,255/255,0/255)
101
                    Frame.BackgroundTransparency = 0
102
                    Frame.BorderSizePixel = 0
103
                    Frame.AnchorPoint = Vector2.new(.5, .5)
104
                    Frame.Position = UDim2.new (0.5,0,0.5,0)
105
                    Frame.Size = UDim2.new (1,0,1,0)
106
                    Frame.Rotation = 0
107
                    plr.Character.Humanoid.Died:Connect(function()
108
                        bill:Destroy()
109
                    end)
110
                end
111
            end
112
            
113
            
114
        end
115
    end
116
end
117
local cam = game.Workspace.CurrentCamera
118
 
119
local mouse = lplr:GetMouse()
120
local switch = false
121
local key = "k"
122
local aimatpart = nil
123
mouse.KeyDown:Connect(function(a)
124
    if a == "t" then
125
        print("worked1")
126
        f.addesp()
127
    elseif a == "u" then
128
        if raycast == true then
129
            raycast = false
130
        else
131
            raycast = true
132
        end
133
    elseif a == "l" then
134
        if autoesp == false then
135
            autoesp = true
136
        else
137
            autoesp = false
138
        end
139
    end
140
    if a == "j" then
141
        if mouse.Target then
142
            mouse.Target:Destroy()
143
        end
144
    end
145
    if a == key then
146
        if switch == false then
147
            switch = true
148
        else
149
            switch = false
150
            if aimatpart ~= nil then
151
                aimatpart = nil
152
            end
153
        end
154
    elseif a == teambasedswitch then
155
        if TeamBased == true then
156
            TeamBased = false
157
            teambasedstatus.Text = tostring(TeamBased)
158
        else
159
            TeamBased = true
160
            teambasedstatus.Text = tostring(TeamBased)
161
        end
162
    elseif a == aimkey then
163
        if not aimatpart then
164
            local maxangle = math.rad(20)
165
            for i, plr in pairs(plrs:GetChildren()) do
166
                if plr.Name ~= lplr.Name and plr.Character and plr.Character.Head and plr.Character.Humanoid and plr.Character.Humanoid.Health > 1 then
167
                    if TeamBased == true then
168
                        if plr.Team.Name ~= lplr.Team.Name then
169
                            local an = checkfov(plr.Character.Head)
170
                            if an < maxangle then
171
                                maxangle = an
172
                                aimatpart = plr.Character.Head
173
                            end
174
                        end
175
                    else
176
                        local an = checkfov(plr.Character.Head)
177
                            if an < maxangle then
178
                                maxangle = an
179
                                aimatpart = plr.Character.Head
180
                            end
181
                            print(plr)
182
                    end
183
                    plr.Character.Humanoid.Died:Connect(function()
184
                        if aimatpart.Parent == plr.Character or aimatpart == nil then
185
                            aimatpart = nil
186
                        end
187
                    end)
188
                end
189
            end
190
        else
191
            aimatpart = nil
192
        end
193
    end
194
end)
195
 
196
function getfovxyz (p0, p1, deg)
197
    local x1, y1, z1 = p0:ToOrientation()
198
    local cf = CFrame.new(p0.p, p1.p)
199
    local x2, y2, z2 = cf:ToOrientation()
200
    --local d = math.deg
201
    if deg then
202
        --return Vector3.new(d(x1-x2), d(y1-y2), d(z1-z2))
203
    else
204
        return Vector3.new((x1-x2), (y1-y2), (z1-z2))
205
    end
206
end
207
 
208
function getaimbotplrs()
209
    plrsforaim = {}
210
    for i, plr in pairs(plrs:GetChildren()) do
211
        if plr.Character and plr.Character.Humanoid and plr.Character.Humanoid.Health > 0 and plr.Name ~= lplr.Name and plr.Character.Head then
212
            
213
            if TeamBased == true then
214
                if plr.Team.Name ~= lplr.Team.Name then
215
                    local cf = CFrame.new(game.Workspace.CurrentCamera.CFrame.p, plr.Character.Head.CFrame.p)
216
                    local r = Ray.new(cf, cf.LookVector * 10000)
217
                    local ign = {}
218
                    for i, v in pairs(plrs.LocalPlayer.Character:GetChildren()) do
219
                        if v:IsA("BasePart") then
220
                            table.insert(ign , v)
221
                        end
222
                    end
223
                    local obj = game.Workspace:FindPartOnRayWithIgnoreList(r, ign)
224
                    if obj.Parent == plr.Character and obj.Parent ~= lplr.Character then
225
                        table.insert(plrsforaim, obj)
226
                    end
227
                end
228
            else
229
                local cf = CFrame.new(game.Workspace.CurrentCamera.CFrame.p, plr.Character.Head.CFrame.p)
230
                local r = Ray.new(cf, cf.LookVector * 10000)
231
                local ign = {}
232
                for i, v in pairs(plrs.LocalPlayer.Character:GetChildren()) do
233
                    if v:IsA("BasePart") then
234
                        table.insert(ign , v)
235
                    end
236
                end
237
                local obj = game.Workspace:FindPartOnRayWithIgnoreList(r, ign)
238
                if obj.Parent == plr.Character and obj.Parent ~= lplr.Character then
239
                    table.insert(plrsforaim, obj)
240
                end
241
            end
242
            
243
            
244
        end
245
    end
246
end
247
 
248
function aimat(part)
249
    cam.CFrame = CFrame.new(cam.CFrame.p, part.CFrame.p)
250
end
251
function checkfov (part)
252
    local fov = getfovxyz(game.Workspace.CurrentCamera.CFrame, part.CFrame)
253
    local angle = math.abs(fov.X) + math.abs(fov.Y)
254
    return angle
255
end
256
 
257
game:GetService("RunService").RenderStepped:Connect(function()
258
    if aimatpart then
259
        aimat(aimatpart)
260
        if aimatpart.Parent == plrs.LocalPlayer.Character then
261
            aimatpart = nil
262
        end
263
    end
264
    
265
    
266
--  if switch == true then
267
--      local maxangle = 99999
268
--      
269
--      --print("Loop")
270
--      if true and raycast == false then
271
--          for i, plr in pairs(plrs:GetChildren()) do
272
--              if plr.Name ~= lplr.Name and plr.Character and plr.Character.Head and plr.Character.Humanoid and plr.Character.Humanoid.Health > 1 then
273
--                  if TeamBased then
274
--                      if plr.Team.Name ~= lplr.Team.Name or plr.Team.TeamColor ~= lplr.Team.TeamColor then
275
--                          local an = checkfov(plr.Character.Head)
276
--                          if an < maxangle then
277
--                              maxangle = an
278
--                              aimatpart = plr.Character.Head
279
--                              if an < lockangle then
280
--                                  break
281
--                              end
282
--                          end
283
--                      end
284
--                  else
285
--                      local an = checkfov(plr.Character.Head)
286
--                          if an < maxangle then
287
--                              maxangle = an
288
--                              aimatpart = plr.Character.Head
289
--                              if an < lockangle then
290
--                                  break
291
--                              end
292
--                          end
293
--                  end
294
--                  
295
--                  
296
--                  
297
--                  
298
--              end
299
--          end
300
--      elseif raycast == true then
301
--          
302
--      end
303
        
304
        if raycast == true and switch == false and not aimatpart then
305
            getaimbotplrs()
306
            aimatpart = nil
307
            local maxangle = 999
308
            for i, v in ipairs(plrsforaim) do
309
                if v.Parent ~= lplr.Character then
310
                    local an = checkfov(v)
311
                    if an < maxangle and v ~= lplr.Character.Head then
312
                        maxangle = an
313
                        aimatpart = v
314
                        print(v:GetFullName())
315
                        v.Parent.Humanoid.Died:connect(function()
316
                            aimatpart = nil
317
                        end)
318
                    end
319
                end
320
            end
321
        
322
    end
323
end)
324
delay(0, function()
325
    while wait(espupdatetime) do
326
        if autoesp == true then
327
            pcall(function()
328
            f.addesp()
329
            end)
330
        end
331
    end
332
end)
333
warn("loaded")