-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp.lua
95 lines (87 loc) · 3.88 KB
/
esp.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
-- Made by Blissful#4992
local Player = game:GetService("Players").LocalPlayer
local Camera = game:GetService("Workspace").CurrentCamera
local Mouse = Player:GetMouse()
local function Dist(pointA, pointB) -- magnitude errors for some reason : (
return math.sqrt(math.pow(pointA.X - pointB.X, 2) + math.pow(pointA.Y - pointB.Y, 2))
end
local function GetClosest(points, dest)
local min = math.huge
local closest = nil
for _,v in pairs(points) do
local dist = Dist(v, dest)
if dist < min then
min = dist
closest = v
end
end
return closest
end
local function DrawESP(plr)
local Box = Drawing.new("Quad")
Box.Visible = false
Box.PointA = Vector2.new(0, 0)
Box.PointB = Vector2.new(0, 0)
Box.PointC = Vector2.new(0, 0)
Box.PointD = Vector2.new(0, 0)
Box.Color = Color3.fromRGB(255, 255, 255)
Box.Thickness = 2
Box.Transparency = 1
local function Update()
local c
c = game:GetService("RunService").RenderStepped:Connect(function()
if plr.Character ~= nil and plr.Character:FindFirstChildOfClass("Humanoid") ~= nil and plr.Character:FindFirstChild("HumanoidRootPart") ~= nil and plr.Character:FindFirstChildOfClass("Humanoid").Health > 0 and plr.Character:FindFirstChild("Head") ~= nil then
local pos, vis = Camera:WorldToViewportPoint(plr.Character.HumanoidRootPart.Position)
if vis then
local points = {}
local c = 0
for _,v in pairs(plr.Character:GetChildren()) do
if v:IsA("BasePart") then
c = c + 1
local p = Camera:WorldToViewportPoint(v.Position)
if v.Name == "HumanoidRootPart" then
p = Camera:WorldToViewportPoint((v.CFrame * CFrame.new(0, 0, -v.Size.Z)).p)
elseif v.Name == "Head" then
p = Camera:WorldToViewportPoint((v.CFrame * CFrame.new(0, v.Size.Y/2, v.Size.Z/1.25)).p)
elseif string.match(v.Name, "Left") then
p = Camera:WorldToViewportPoint((v.CFrame * CFrame.new(-v.Size.X/2, 0, 0)).p)
elseif string.match(v.Name, "Right") then
p = Camera:WorldToViewportPoint((v.CFrame * CFrame.new(v.Size.X/2, 0, 0)).p)
end
points[c] = p
end
end
local Left = GetClosest(points, Vector2.new(0, pos.Y))
local Right = GetClosest(points, Vector2.new(Camera.ViewportSize.X, pos.Y))
local Top = GetClosest(points, Vector2.new(pos.X, 0))
local Bottom = GetClosest(points, Vector2.new(pos.X, Camera.ViewportSize.Y))
if Left ~= nil and Right ~= nil and Top ~= nil and Bottom ~= nil then
Box.PointA = Vector2.new(Right.X, Top.Y)
Box.PointB = Vector2.new(Left.X, Top.Y)
Box.PointC = Vector2.new(Left.X, Bottom.Y)
Box.PointD = Vector2.new(Right.X, Bottom.Y)
Box.Visible = true
else
Box.Visible = false
end
else
Box.Visible = false
end
else
Box.Visible = false
if game.Players:FindFirstChild(plr.Name) == nil then
c:Disconnect()
end
end
end)
end
coroutine.wrap(Update)()
end
for _,v in pairs(game:GetService("Players"):GetChildren()) do
if v.Name ~= Player.Name then
DrawESP(v)
end
end
game:GetService("Players").PlayerAdded:Connect(function(v)
DrawESP(v)
end)