
KeylessUniversal

local player = game.Players.LocalPlayer
local myUsername = player.Name
-- [[ 核心配置参数 ]]
local R15_PER_PART = false
local R6_PER_PART = true
-- 获取血量颜色逻辑 (原版一字不动)
local function getHealthColor(humanoid)
local healthPercent = math.clamp(humanoid.Health / humanoid.MaxHealth, 0, 1)
if humanoid.MaxHealth >= 9e9 or healthPercent >= 1 then
return Color3.fromRGB(255, 255, 255)
elseif healthPercent > 0.5 then
local t = (healthPercent - 0.5) / 0.5
return Color3.fromRGB(255, 255, 0):Lerp(Color3.fromRGB(27, 252, 107), t)
elseif healthPercent > 0 then
local t = healthPercent / 0.5
return Color3.fromRGB(255, 0, 0):Lerp(Color3.fromRGB(255, 255, 0), t)
else
return Color3.fromRGB(255, 0, 0)
end
end
-- 1. 管理系统与缓存
local managedParts = {}
local checkedCache = {}
local function applyHighlight(target, model, isTool)
if managedParts[target] then return end
local data = {
highlight = Instance.new("Highlight"),
deathBurstHandled = false,
sourceModel = model,
feedbackTimer = isTool and 1.0 or 0
}
local h = data.highlight
h.Name = "ManagedHighlight"
h.DepthMode = Enum.HighlightDepthMode.Occluded
h.FillTransparency = 0
h.OutlineTransparency = 0
h.FillColor = Color3.fromRGB(255, 255, 255)
h.OutlineColor = Color3.fromRGB(255, 255, 255)
h.Adornee = target
h.Parent = target
managedParts[target] = data
end
-- 2. 核心:【慢慢侦测】逻辑 (降低 CPU 峰值)
task.spawn(function()
while true do
-- 每隔 1 秒扫描一次场上的新对象
for _, obj in ipairs(game.Workspace:GetDescendants()) do
if not checkedCache[obj] then
checkedCache[obj] = true
local model = (obj:IsA("Model") and obj) or (obj:IsA("BasePart") and obj:FindFirstAncestorOfClass("Model"))
if model then
local hum = model:FindFirstChildOfClass("Humanoid")
local isMatch = model.Name:find(myUsername) or (hum and (hum.DisplayName:find(myUsername) or hum.Name:find(myUsername)))
if isMatch then
local usePerPart = hum and ((hum.RigType == Enum.HumanoidRigType.R15 and R15_PER_PART) or (hum.RigType == Enum.HumanoidRigType.R6 and R6_PER_PART))
if usePerPart then
if obj:IsA("BasePart") then applyHighlight(obj, model, obj:FindFirstAncestorOfClass("Tool") ~= nil) end
else
if obj == model then applyHighlight(model, model, false) end
end
end
end
end
end
task.wait(1) -- 【关键修改:1秒侦测一次】
end
end)
-- 3. 核心:【快速渲染】逻辑 (保持视觉流畅)
task.spawn(function()
local t_rainbow = 0
local t_death = 0
while true do
for part, data in pairs(managedParts) do
if not part:IsDescendantOf(game.Workspace) then
if data.highlight then data.highlight:Destroy() end
managedParts[part] = nil
checkedCache[part] = nil
else
local h = data.highlight
local hum = data.sourceModel:FindFirstChildOfClass("Humanoid")
local isDead = hum and hum.Health <= 0
local inWhiteMode = data.sourceModel:FindFirstChildOfClass("ForceField") or (hum and hum.MaxHealth >= 9e9)
if data.feedbackTimer > 0 then data.feedbackTimer = math.max(0, data.feedbackTimer - 0.05) end
if isDead then
-- 【死亡爆发时序:白 -> 0.03 深红】
if not data.deathBurstHandled then
h.FillColor = Color3.fromRGB(255, 255, 255)
h.OutlineColor = Color3.fromRGB(255, 255, 255)
data.deathBurstHandled = true
end
t_death = t_death + 0.35
local targetOutline = Color3.fromRGB(255, 0, 0):Lerp(Color3.fromRGB(255, 0, 150), (math.sin(t_death) + 1) / 2)
h.OutlineColor = h.OutlineColor:Lerp(targetOutline, 0.15)
h.FillColor = h.FillColor:Lerp(Color3.fromRGB(120, 0, 10):Lerp(targetOutline, 0.1), 0.03) -- 0.03 慢速变色
elseif inWhiteMode then
-- 【彩虹白色模式】
local r, g, b = math.sin(t_rainbow)*127+128, math.sin(t_rainbow+2)*127+128, math.sin(t_rainbow+4)*127+128
h.FillColor = h.FillColor:Lerp(Color3.fromRGB(255, 255, 255), 0.2)
h.OutlineColor = h.OutlineColor:Lerp(Color3.fromRGB(r, g, b):Lerp(Color3.fromRGB(255, 255, 255), data.feedbackTimer), 0.2)
data.deathBurstHandled = false
else
-- 【普通模式:黑 Fill + 变白反馈】
local hColor = hum and getHealthColor(hum) or Color3.fromRGB(255, 255, 255)
h.FillColor = h.FillColor:Lerp(Color3.fromRGB(0, 0, 0):Lerp(Color3.fromRGB(255, 255, 255), data.feedbackTimer), 0.04)
h.OutlineColor = h.OutlineColor:Lerp(hColor:Lerp(Color3.fromRGB(255, 255, 255), data.feedbackTimer), 0.12)
data.deathBurstHandled = false
end
end
end
t_rainbow = t_rainbow + 0.1
task.wait(0.02) -- 【视觉层依然保持高帧率运行】
end
end)No comments yet for this script.



