-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathESP_LIB.lua
415 lines (366 loc) · 18.5 KB
/
ESP_LIB.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
-- modified, full credit to linemaster2
--// Variables
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera
local cache = {}
local bones = {
{"Head", "UpperTorso"},
{"UpperTorso", "RightUpperArm"},
{"RightUpperArm", "RightLowerArm"},
{"RightLowerArm", "RightHand"},
{"UpperTorso", "LeftUpperArm"},
{"LeftUpperArm", "LeftLowerArm"},
{"LeftLowerArm", "LeftHand"},
{"UpperTorso", "LowerTorso"},
{"LowerTorso", "LeftUpperLeg"},
{"LeftUpperLeg", "LeftLowerLeg"},
{"LeftLowerLeg", "LeftFoot"},
{"LowerTorso", "RightUpperLeg"},
{"RightUpperLeg", "RightLowerLeg"},
{"RightLowerLeg", "RightFoot"}
}
--// Settings
local ESP_SETTINGS = {
BoxOutlineColor = Color3.new(0, 0, 0),
BoxColor = Color3.new(1, 1, 1),
NameColor = Color3.new(1, 1, 1),
HealthOutlineColor = Color3.new(0, 0, 0),
HealthHighColor = Color3.new(0, 1, 0),
HealthLowColor = Color3.new(1, 0, 0),
CharSize = Vector2.new(4, 6),
Teamcheck = false,
WallCheck = false,
Enabled = false,
ShowBox = false,
BoxType = "2D",
ShowName = false,
ShowHealth = false,
ShowDistance = false,
ShowSkeletons = false,
ShowTracer = false,
TracerColor = Color3.new(1, 1, 1),
TracerThickness = 2,
SkeletonsColor = Color3.new(1, 1, 1),
TracerPosition = "Bottom",
MaxDistance = 500,
}
local function create(class, properties)
local drawing = Drawing.new(class)
for property, value in pairs(properties) do
drawing[property] = value
end
return drawing
end
local function createEsp(player)
local esp = {
tracer = create("Line", {
Thickness = ESP_SETTINGS.TracerThickness,
Color = ESP_SETTINGS.TracerColor,
Transparency = 0.5
}),
boxOutline = create("Square", {
Color = ESP_SETTINGS.BoxOutlineColor,
Thickness = 3,
Filled = false
}),
box = create("Square", {
Color = ESP_SETTINGS.BoxColor,
Thickness = 1,
Filled = false
}),
name = create("Text", {
Color = ESP_SETTINGS.NameColor,
Outline = true,
Center = true,
Size = 13
}),
healthOutline = create("Line", {
Thickness = 3,
Color = ESP_SETTINGS.HealthOutlineColor
}),
health = create("Line", {
Thickness = 1
}),
distance = create("Text", {
Color = Color3.new(1, 1, 1),
Size = 12,
Outline = true,
Center = true
}),
tracer = create("Line", {
Thickness = ESP_SETTINGS.TracerThickness,
Color = ESP_SETTINGS.TracerColor,
Transparency = 1
}),
boxLines = {},
}
cache[player] = esp
cache[player]["skeletonlines"] = {}
end
local function isPlayerBehindWall(player)
local character = player.Character
if not character then
return false
end
local rootPart = character:FindFirstChild("HumanoidRootPart")
if not rootPart then
return false
end
local ray = Ray.new(camera.CFrame.Position, (rootPart.Position - camera.CFrame.Position).Unit * (rootPart.Position - camera.CFrame.Position).Magnitude)
local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, {localPlayer.Character, character})
return hit and hit:IsA("Part")
end
local function removeEsp(player)
local esp = cache[player]
if not esp then return end
for _, drawing in pairs(esp) do
if drawing then
drawing:Remove()
end
end
cache[player] = nil
end
local function updateEsp()
for player, esp in pairs(cache) do
local character, team = player.Character, player.Team
if character and (not ESP_SETTINGS.Teamcheck or (team and team ~= localPlayer.Team)) then
local rootPart = character:FindFirstChild("HumanoidRootPart")
local head = character:FindFirstChild("Head")
local humanoid = character:FindFirstChild("Humanoid")
local isBehindWall = ESP_SETTINGS.WallCheck and isPlayerBehindWall(player)
local distance = (camera.CFrame.p - rootPart.Position).Magnitude
local shouldShow = not isBehindWall and ESP_SETTINGS.Enabled
if rootPart and head and humanoid and shouldShow and distance <= ESP_SETTINGS.MaxDistance then
local position, onScreen = camera:WorldToViewportPoint(rootPart.Position)
if onScreen then
local hrp2D = camera:WorldToViewportPoint(rootPart.Position)
local charSize = (camera:WorldToViewportPoint(rootPart.Position - Vector3.new(0, 3, 0)).Y - camera:WorldToViewportPoint(rootPart.Position + Vector3.new(0, 2.6, 0)).Y) / 2
local boxSize = Vector2.new(math.floor(charSize * 1.8), math.floor(charSize * 1.9))
local boxPosition = Vector2.new(math.floor(hrp2D.X - charSize * 1.8 / 2), math.floor(hrp2D.Y - charSize * 1.6 / 2))
if ESP_SETTINGS.ShowName and ESP_SETTINGS.Enabled then
esp.name.Visible = true
esp.name.Text = string.lower(player.Name)
esp.name.Position = Vector2.new(boxSize.X / 2 + boxPosition.X, boxPosition.Y - 16)
esp.name.Color = ESP_SETTINGS.NameColor
else
esp.name.Visible = false
end
if ESP_SETTINGS.ShowBox and ESP_SETTINGS.Enabled then
if ESP_SETTINGS.BoxType == "2D" then
esp.boxOutline.Size = boxSize
esp.boxOutline.Position = boxPosition
esp.box.Size = boxSize
esp.box.Position = boxPosition
esp.box.Color = ESP_SETTINGS.BoxColor
esp.box.Visible = true
esp.boxOutline.Visible = true
for _, line in ipairs(esp.boxLines) do
line:Remove()
end
elseif ESP_SETTINGS.BoxType == "Corner Box Esp" then
local lineW = (boxSize.X / 5)
local lineH = (boxSize.Y / 6)
local lineT = 1
if #esp.boxLines == 0 then
for i = 1, 16 do
local boxLine = create("Line", {
Thickness = 1,
Color = ESP_SETTINGS.BoxColor,
Transparency = 1
})
esp.boxLines[#esp.boxLines + 1] = boxLine
end
end
local boxLines = esp.boxLines
-- top left
boxLines[1].From = Vector2.new(boxPosition.X - lineT, boxPosition.Y - lineT)
boxLines[1].To = Vector2.new(boxPosition.X + lineW, boxPosition.Y - lineT)
boxLines[2].From = Vector2.new(boxPosition.X - lineT, boxPosition.Y - lineT)
boxLines[2].To = Vector2.new(boxPosition.X - lineT, boxPosition.Y + lineH)
-- top right
boxLines[3].From = Vector2.new(boxPosition.X + boxSize.X - lineW, boxPosition.Y - lineT)
boxLines[3].To = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y - lineT)
boxLines[4].From = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y - lineT)
boxLines[4].To = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y + lineH)
-- bottom left
boxLines[5].From = Vector2.new(boxPosition.X - lineT, boxPosition.Y + boxSize.Y - lineH)
boxLines[5].To = Vector2.new(boxPosition.X - lineT, boxPosition.Y + boxSize.Y + lineT)
boxLines[6].From = Vector2.new(boxPosition.X - lineT, boxPosition.Y + boxSize.Y + lineT)
boxLines[6].To = Vector2.new(boxPosition.X + lineW, boxPosition.Y + boxSize.Y + lineT)
-- bottom right
boxLines[7].From = Vector2.new(boxPosition.X + boxSize.X - lineW, boxPosition.Y + boxSize.Y + lineT)
boxLines[7].To = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y + boxSize.Y + lineT)
boxLines[8].From = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y + boxSize.Y - lineH)
boxLines[8].To = Vector2.new(boxPosition.X + boxSize.X + lineT, boxPosition.Y + boxSize.Y + lineT)
-- inline
for i = 9, 16 do
boxLines[i].Thickness = 2
boxLines[i].Color = ESP_SETTINGS.BoxOutlineColor
boxLines[i].Transparency = 1
end
boxLines[9].From = Vector2.new(boxPosition.X, boxPosition.Y)
boxLines[9].To = Vector2.new(boxPosition.X, boxPosition.Y + lineH)
boxLines[10].From = Vector2.new(boxPosition.X, boxPosition.Y)
boxLines[10].To = Vector2.new(boxPosition.X + lineW, boxPosition.Y)
boxLines[11].From = Vector2.new(boxPosition.X + boxSize.X - lineW, boxPosition.Y)
boxLines[11].To = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y)
boxLines[12].From = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y)
boxLines[12].To = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y + lineH)
boxLines[13].From = Vector2.new(boxPosition.X, boxPosition.Y + boxSize.Y - lineH)
boxLines[13].To = Vector2.new(boxPosition.X, boxPosition.Y + boxSize.Y)
boxLines[14].From = Vector2.new(boxPosition.X, boxPosition.Y + boxSize.Y)
boxLines[14].To = Vector2.new(boxPosition.X + lineW, boxPosition.Y + boxSize.Y)
boxLines[15].From = Vector2.new(boxPosition.X + boxSize.X - lineW, boxPosition.Y + boxSize.Y)
boxLines[15].To = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y + boxSize.Y)
boxLines[16].From = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y + boxSize.Y - lineH)
boxLines[16].To = Vector2.new(boxPosition.X + boxSize.X, boxPosition.Y + boxSize.Y)
for _, line in ipairs(boxLines) do
line.Visible = true
end
esp.box.Visible = false
esp.boxOutline.Visible = false
end
else
esp.box.Visible = false
esp.boxOutline.Visible = false
for _, line in ipairs(esp.boxLines) do
line:Remove()
end
esp.boxLines = {}
end
if ESP_SETTINGS.ShowHealth and ESP_SETTINGS.Enabled then
esp.healthOutline.Visible = true
esp.health.Visible = true
local healthPercentage = player.Character.Humanoid.Health / player.Character.Humanoid.MaxHealth
esp.healthOutline.From = Vector2.new(boxPosition.X - 6, boxPosition.Y + boxSize.Y)
esp.healthOutline.To = Vector2.new(esp.healthOutline.From.X, esp.healthOutline.From.Y - boxSize.Y)
esp.health.From = Vector2.new((boxPosition.X - 5), boxPosition.Y + boxSize.Y)
esp.health.To = Vector2.new(esp.health.From.X, esp.health.From.Y - (player.Character.Humanoid.Health / player.Character.Humanoid.MaxHealth) * boxSize.Y)
esp.health.Color = ESP_SETTINGS.HealthLowColor:Lerp(ESP_SETTINGS.HealthHighColor, healthPercentage)
else
esp.healthOutline.Visible = false
esp.health.Visible = false
end
if ESP_SETTINGS.ShowDistance and ESP_SETTINGS.Enabled then
local distance = (camera.CFrame.p - rootPart.Position).Magnitude
esp.distance.Text = string.format("%.1f studs", distance)
esp.distance.Position = Vector2.new(boxPosition.X + boxSize.X / 2, boxPosition.Y + boxSize.Y + 5)
esp.distance.Visible = true
else
esp.distance.Visible = false
end
if ESP_SETTINGS.ShowSkeletons and ESP_SETTINGS.Enabled then
if #esp["skeletonlines"] == 0 then
for _, bonePair in ipairs(bones) do
local parentBone, childBone = bonePair[1], bonePair[2]
if player.Character and player.Character[parentBone] and player.Character[childBone] then
local skeletonLine = create("Line", {
Thickness = 1,
Color = ESP_SETTINGS.SkeletonsColor,
Transparency = 1
})
esp["skeletonlines"][#esp["skeletonlines"] + 1] = {skeletonLine, parentBone, childBone}
end
end
end
for _, lineData in ipairs(esp["skeletonlines"]) do
local skeletonLine = lineData[1]
local parentBone, childBone = lineData[2], lineData[3]
if player.Character and player.Character[parentBone] and player.Character[childBone] then
local parentPosition = camera:WorldToViewportPoint(player.Character[parentBone].Position)
local childPosition = camera:WorldToViewportPoint(player.Character[childBone].Position)
skeletonLine.From = Vector2.new(parentPosition.X, parentPosition.Y)
skeletonLine.To = Vector2.new(childPosition.X, childPosition.Y)
skeletonLine.Color = ESP_SETTINGS.SkeletonsColor
skeletonLine.Visible = true
else
skeletonLine:Remove()
end
end
else
for _, lineData in ipairs(esp["skeletonlines"]) do
local skeletonLine = lineData[1]
skeletonLine:Remove()
end
esp["skeletonlines"] = {}
end
if ESP_SETTINGS.ShowTracer and ESP_SETTINGS.Enabled then
local tracerY
if ESP_SETTINGS.TracerPosition == "Top" then
tracerY = 0
elseif ESP_SETTINGS.TracerPosition == "Middle" then
tracerY = camera.ViewportSize.Y / 2
else
tracerY = camera.ViewportSize.Y
end
if ESP_SETTINGS.Teamcheck and player.TeamColor == localPlayer.TeamColor then
esp.tracer.Visible = false
else
esp.tracer.Visible = true
esp.tracer.From = Vector2.new(camera.ViewportSize.X / 2, tracerY)
esp.tracer.To = Vector2.new(hrp2D.X, hrp2D.Y)
end
else
esp.tracer.Visible = false
end
else
for _, drawing in pairs(esp) do
drawing.Visible = false
end
for _, lineData in ipairs(esp["skeletonlines"]) do
local skeletonLine = lineData[1]
skeletonLine:Remove()
end
esp["skeletonlines"] = {}
for _, line in ipairs(esp.boxLines) do
line:Remove()
end
esp.boxLines = {}
end
else
for _, drawing in pairs(esp) do
drawing.Visible = false
end
for _, lineData in ipairs(esp["skeletonlines"]) do
local skeletonLine = lineData[1]
skeletonLine:Remove()
end
esp["skeletonlines"] = {}
for _, line in ipairs(esp.boxLines) do
line:Remove()
end
esp.boxLines = {}
end
else
for _, drawing in pairs(esp) do
drawing.Visible = false
end
for _, lineData in ipairs(esp["skeletonlines"]) do
local skeletonLine = lineData[1]
skeletonLine:Remove()
end
esp["skeletonlines"] = {}
for _, line in ipairs(esp.boxLines) do
line:Remove()
end
esp.boxLines = {}
end
end
end
for _, player in ipairs(Players:GetPlayers()) do
if player ~= localPlayer then
createEsp(player)
end
end
Players.PlayerAdded:Connect(function(player)
if player ~= localPlayer then
createEsp(player)
end
end)
Players.PlayerRemoving:Connect(function(player)
removeEsp(player)
end)
RunService.RenderStepped:Connect(updateEsp)
return ESP_SETTINGS