local Players = game:GetService("Players") local CoreGui = game:GetService("CoreGui") local RunService = game:GetService("RunService") local LP = Players.LocalPlayer local ENEMY = Color3.fromRGB(255, 40, 40) local ALLY = Color3.fromRGB(40, 140, 255) local MAX_RANGE = 10000 local UPDATE_RATE = 0.2 local Holder = Instance.new("Folder") Holder.Name = "\0" Holder.Parent = CoreGui -- cache: plr -> {highlight, root, character} local tracked = {} local function isAlly(plr) if not plr or plr == LP then return true end local lpTeam, pTeam = LP.Team, plr.Team if not lpTeam or not pTeam then return false end return lpTeam.TeamColor == pTeam.TeamColor end local function getRoot(char) return char and (char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")) end local function cleanup(plr) local data = tracked[plr] if data then if data.hl then data.hl:Destroy() end tracked[plr] = nil end end local function build(plr, char) if not char then return end cleanup(plr) local hum = char:WaitForChild("Humanoid", 5) if not hum then return end local color = isAlly(plr) and ALLY or ENEMY local hl = Instance.new("Highlight") hl.Name = "\0" hl.Adornee = char hl.FillTransparency = 0.5 hl.OutlineTransparency = 0 hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop hl.FillColor = color hl.OutlineColor = color hl.Enabled = false hl.Parent = Holder tracked[plr] = {hl = hl, char = char, root = getRoot(char)} hum.Died:Connect(function() cleanup(plr) end) char.AncestryChanged:Connect(function(_, parent) if not parent then cleanup(plr) end end) end local function applyChams(plr) if plr.Character then build(plr, plr.Character) end plr.CharacterAdded:Connect(function(c) build(plr, c) end) plr:GetPropertyChangedSignal("Team"):Connect(function() local data = tracked[plr] if data and data.hl then local c = isAlly(plr) and ALLY or ENEMY data.hl.FillColor = c data.hl.OutlineColor = c end end) end for _, p in ipairs(Players:GetPlayers()) do if p ~= LP then applyChams(p) end end Players.PlayerAdded:Connect(function(p) if p ~= LP then applyChams(p) end end) Players.PlayerRemoving:Connect(cleanup) -- throttled range loop local accum = 0 RunService.Heartbeat:Connect(function(dt) accum = accum + dt if accum < UPDATE_RATE then return end accum = 0 local lpChar = LP.Character local lpRoot = getRoot(lpChar) if not lpRoot then return end local lpPos = lpRoot.Position for plr, data in pairs(tracked) do local root = data.root if not root or not root.Parent then root = getRoot(data.char) data.root = root end if root then local dist = (root.Position - lpPos).Magnitude data.hl.Enabled = dist <= MAX_RANGE else data.hl.Enabled = false end end end)