-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathESPV2
More file actions
144 lines (134 loc) · 7 KB
/
Copy pathESPV2
File metadata and controls
144 lines (134 loc) · 7 KB
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
local Config = {
Box = false,
BoxOutline = false,
BoxColor = Color3.fromRGB(255,255,255),
BoxOutlineColor = Color3.fromRGB(0,0,0),
HealthBar = false,
HealthBarSide = "Left", -- Left,Bottom,Right
Names = false,
NamesOutline = false,
NamesColor = Color3.fromRGB(255,255,255),
NamesOutlineColor = Color3.fromRGB(0,0,0),
NamesFont = 2, -- 0,1,2,3
NamesSize = 13,
TeamCheck = false
}
function CreateEsp(Player)
local Box,BoxOutline,Name,HealthBar,HealthBarOutline = Drawing.new("Square"),Drawing.new("Square"),Drawing.new("Text"),Drawing.new("Square"),Drawing.new("Square")
local Updater = game:GetService("RunService").RenderStepped:Connect(function()
if Player.Character ~= nil and Player.Character:FindFirstChild("Humanoid") ~= nil and Player.Character:FindFirstChild("HumanoidRootPart") ~= nil and Player.Character.Humanoid.Health > 0 and Player.Character:FindFirstChild("Head") ~= nil then
local Target2dPosition,IsVisible = workspace.CurrentCamera:WorldToViewportPoint(Player.Character.HumanoidRootPart.Position)
local scale_factor = 1 / (Target2dPosition.Z * math.tan(math.rad(workspace.CurrentCamera.FieldOfView * 0.5)) * 2) * 100
local width, height = math.floor(40 * scale_factor), math.floor(60 * scale_factor)
if Config.Box then
Box.Visible = IsVisible
Box.Color = Config.BoxColor
Box.Size = Vector2.new(width,height)
Box.Position = Vector2.new(Target2dPosition.X - Box.Size.X / 2,Target2dPosition.Y - Box.Size.Y / 2)
Box.Thickness = 1
Box.ZIndex = 69
if Config.BoxOutline then
BoxOutline.Visible = IsVisible
BoxOutline.Color = Config.BoxOutlineColor
BoxOutline.Size = Vector2.new(width,height)
BoxOutline.Position = Vector2.new(Target2dPosition.X - Box.Size.X / 2,Target2dPosition.Y - Box.Size.Y / 2)
BoxOutline.Thickness = 3
BoxOutline.ZIndex = 1
else
BoxOutline.Visible = false
end
else
Box.Visible = false
BoxOutline.Visible = false
end
if Config.Names then
Name.Visible = IsVisible
Name.Color = Config.NamesColor
Name.Text = Player.Name.." "..math.floor((workspace.CurrentCamera.CFrame.p - Player.Character.HumanoidRootPart.Position).magnitude).."m"
Name.Center = true
Name.Outline = Config.NamesOutline
Name.OutlineColor = Config.NamesOutlineColor
Name.Position = Vector2.new(Target2dPosition.X,Target2dPosition.Y - height * 0.5 + -15)
Name.Font = Config.NamesFont
Name.Size = Config.NamesSize
else
Name.Visible = false
end
if Config.TeamCheck then
if Player.Team ~= game.Players.LocalPlayer.Team then
else
Box.Visible = false
BoxOutline.Visible = false
Name.Visible = false
HealthBar.Visible = false
HealthBarOutline.Visible = false
if not Player then
Box:Remove()
BoxOutline:Remove()
Name:Remove()
HealthBar:Remove()
HealthBarOutline:Remove()
Updater:Disconnect()
end
end
end
if Config.HealthBar then
HealthBarOutline.Visible = IsVisible
HealthBarOutline.Color = Color3.fromRGB(0,0,0)
HealthBarOutline.Filled = true
HealthBarOutline.ZIndex = 1
HealthBar.Visible = IsVisible
HealthBar.Color = Color3.fromRGB(255,0,0):lerp(Color3.fromRGB(0,255,0), Player.Character:FindFirstChild("Humanoid").Health/Player.Character:FindFirstChild("Humanoid").MaxHealth)
HealthBar.Thickness = 1
HealthBar.Filled = true
HealthBar.ZIndex = 69
if Config.HealthBarSide == "Left" then
HealthBarOutline.Size = Vector2.new(2,height)
HealthBarOutline.Position = Vector2.new(Target2dPosition.X - Box.Size.X / 2,Target2dPosition.Y - Box.Size.Y / 2) + Vector2.new(-3,0)
HealthBar.Size = Vector2.new(1,-(HealthBarOutline.Size.Y - 2) * (Player.Character:FindFirstChild("Humanoid").Health/Player.Character:FindFirstChild("Humanoid").MaxHealth))
HealthBar.Position = HealthBarOutline.Position + Vector2.new(1,-1 + HealthBarOutline.Size.Y)
elseif Config.HealthBarSide == "Bottom" then
HealthBarOutline.Size = Vector2.new(width,3)
HealthBarOutline.Position = Vector2.new(Target2dPosition.X - Box.Size.X / 2,Target2dPosition.Y - Box.Size.Y / 2) + Vector2.new(0,height + 2)
HealthBar.Size = Vector2.new((HealthBarOutline.Size.X - 2) * (Player.Character:FindFirstChild("Humanoid").Health/Player.Character:FindFirstChild("Humanoid").MaxHealth),1)
HealthBar.Position = HealthBarOutline.Position + Vector2.new(1,-1 + HealthBarOutline.Size.Y)
elseif Config.HealthBarSide == "Right" then
HealthBarOutline.Size = Vector2.new(2,height)
HealthBarOutline.Position = Vector2.new(Target2dPosition.X - Box.Size.X / 2,Target2dPosition.Y - Box.Size.Y / 2) + Vector2.new(width + 1,0)
HealthBar.Size = Vector2.new(1,-(HealthBarOutline.Size.Y - 2) * (Player.Character:FindFirstChild("Humanoid").Health/Player.Character:FindFirstChild("Humanoid").MaxHealth))
HealthBar.Position = HealthBarOutline.Position + Vector2.new(1,-1 + HealthBarOutline.Size.Y)
end
else
HealthBar.Visible = false
HealthBarOutline.Visible = false
end
else
Box.Visible = false
BoxOutline.Visible = false
Name.Visible = false
HealthBar.Visible = false
HealthBarOutline.Visible = false
if not Player then
Box:Remove()
BoxOutline:Remove()
Name:Remove()
HealthBar:Remove()
HealthBarOutline:Remove()
Updater:Disconnect()
end
end
end)
end
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= game:GetService("Players").LocalPlayer then
CreateEsp(v)
v.CharacterAdded:Connect(CreateEsp(v))
end
end
game:GetService("Players").PlayerAdded:Connect(function(v)
if v ~= game:GetService("Players").LocalPlayer then
CreateEsp(v)
v.CharacterAdded:Connect(CreateEsp(v))
end
end)
return Config