
KeylessUniversal

--// Super Stable & Optimized ESP (Fixed)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local LocalPlayer = Players.LocalPlayer
local ESP = {}
local PlayerIndex = {}
local MAX_DISTANCE = 1200
local MIN_BOX = 28
-- Drawing Helpers
local function Line()
local l = Drawing.new("Line")
l.Color = Color3.new(1, 1, 1)
l.Thickness = 1
l.Visible = false
return l
end
local function Box()
local b = Drawing.new("Square")
b.Color = Color3.new(1, 1, 1)
b.Thickness = 1
b.Filled = false
b.Visible = false
return b
end
local function Text()
local t = Drawing.new("Text")
t.Color = Color3.new(1, 1, 1)
t.Size = 16
t.Center = true
t.Outline = true
t.Visible = false
return t
end
local function WTVP(pos)
local v, visible = Camera:WorldToViewportPoint(pos)
return Vector2.new(v.X, v.Y), visible, v.Z
end
local function Hide(data)
if not data then return end
data.Box.Visible = false
data.Text.Visible = false
for _, l in pairs(data.Skeleton) do
l.Visible = false
end
end
local function CreateSkeleton()
return {
Head = Line(),
Torso = Line(),
LArm = Line(),
RArm = Line(),
LLeg = Line(),
RLeg = Line()
}
end
-- FIXED: Added IsDescendantOf checks so it doesn't read deleted parts
local function Draw(p1, p2, line)
if not p1 or not p2 or not p1:IsDescendantOf(workspace) or not p2:IsDescendantOf(workspace) then
line.Visible = false
return
end
local a, va, za = WTVP(p1.Position)
local b, vb, zb = WTVP(p2.Position)
if za > 0 and zb > 0 then
line.From = a
line.To = b
line.Visible = true
else
line.Visible = false
end
end
-- Cache Character Parts
local function Cache(player, char)
if not char then return end
local function Get(name)
return char:FindFirstChild(name)
end
if not ESP[player] then return end
ESP[player].Parts = {
Head = Get("Head"),
Root = Get("HumanoidRootPart"),
Torso = Get("UpperTorso") or Get("Torso"),
LArm = Get("LeftUpperArm") or Get("Left Arm"),
RArm = Get("RightUpperArm") or Get("Right Arm"),
LLeg = Get("LeftLowerLeg") or Get("Left Leg"), -- Fixed R15 lower leg mapping
RLeg = Get("RightLowerLeg") or Get("Right Leg")
}
end
local function CreateESP(player)
PlayerIndex[player] = true
ESP[player] = {
Box = Box(),
Text = Text(),
Skeleton = CreateSkeleton(),
Parts = nil
}
if player.Character then
Cache(player, player.Character)
end
player.CharacterAdded:Connect(function(char)
task.wait(0.2) -- Small buffer to let limbs load
Cache(player, char)
end)
end
local function RemoveESP(player)
PlayerIndex[player] = nil
local data = ESP[player]
if not data then return end
data.Box:Remove()
data.Text:Remove()
for _, l in pairs(data.Skeleton) do
l:Remove()
end
ESP[player] = nil
end
-- Initialize Players
for _, p in pairs(Players:GetPlayers()) do
if p ~= LocalPlayer then
CreateESP(p)
end
end
Players.PlayerAdded:Connect(function(p)
if p ~= LocalPlayer then
CreateESP(p)
end
end)
Players.PlayerRemoving:Connect(RemoveESP)
-- MAIN LOOP (Optimized)
-- Switched from RenderStepped to PostSimulation to keep FPS high.
RunService.PostSimulation:Connect(function()
for player in pairs(PlayerIndex) do
local data = ESP[player]
if not data then continue end
local char = player.Character
local parts = data.Parts
-- Auto-recover missing parts safely
if char and (not parts or not parts.Root or not parts.Head or not parts.Root:IsDescendantOf(workspace)) then
Cache(player, char)
parts = ESP[player].Parts
end
if not parts then
Hide(data)
continue
end
local head = parts.Head
local root = parts.Root
if not head or not root or not root:IsDescendantOf(workspace) then
Hide(data)
continue
end
local headPos, vis1, z1 = WTVP(head.Position + Vector3.new(0, 0.5, 0))
local rootPos, vis2, z2 = WTVP(root.Position)
if z1 <= 0 or z2 <= 0 then
Hide(data)
continue
end
local distance = (Camera.CFrame.Position - root.Position).Magnitude
if distance > MAX_DISTANCE then
Hide(data)
continue
end
local height = math.abs(headPos.Y - rootPos.Y) * 2
height = math.max(height, MIN_BOX)
local width = height / 1.5 -- Standardized box width aspect ratio
data.Box.Size = Vector2.new(width, height)
data.Box.Position = Vector2.new(rootPos.X - width / 2, rootPos.Y - height / 2)
data.Box.Visible = true
data.Text.Position = Vector2.new(rootPos.X, rootPos.Y - height / 2 - 15)
data.Text.Text = string.format("%s [%d studs]", player.Name, math.floor(distance))
data.Text.Visible = true
-- Skeleton Drawing
local sk = data.Skeleton
local centerJoint = parts.Torso or root
Draw(head, centerJoint, sk.Head)
Draw(centerJoint, root, sk.Torso)
Draw(centerJoint, parts.LArm, sk.LArm)
Draw(centerJoint, parts.RArm, sk.RArm)
Draw(root, parts.LLeg, sk.LLeg)
Draw(root, parts.RLeg, sk.RLeg)
end
end)No comments yet for this script.



