local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Workspace = game:GetService("Workspace") local CoreGui = game:GetService("CoreGui") local localPlayer = Players.LocalPlayer local camera = Workspace.CurrentCamera -- State local enabled = true local highlightFolder = Instance.new("Folder") highlightFolder.Name = "ESP_Highlights" highlightFolder.Parent = CoreGui -- <== changed from PlayerGui -- Function to check if a part is visible (on screen and not blocked) local function isPartVisible(part) if not part or not part.Parent then return false end -- Check if on screen local vector, inViewport = camera:WorldToViewportPoint(part.Position) local onScreen = inViewport and vector.Z > 0 if not onScreen then return false end -- Raycast from camera to part with very long distance local ray = camera:ViewportPointToRay(vector.X, vector.Y) local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Blacklist raycastParams.FilterDescendantsInstances = {localPlayer.Character, part} local result = Workspace:Raycast(ray.Origin, ray.Direction * 10000, raycastParams) -- Visible if ray hits nothing or hits the part itself return not result or result.Instance == part end -- Function to update outlines for all other players local function updateOutlines() -- Clear old highlights for _, child in ipairs(highlightFolder:GetChildren()) do child:Destroy() end -- Only run if ESP is enabled if not enabled then return end -- Loop through all other players for _, player in ipairs(Players:GetPlayers()) do if player ~= localPlayer and player.Character then local character = player.Character local rootPart = character:FindFirstChild("HumanoidRootPart") if rootPart then -- Check visibility local isVisible = isPartVisible(rootPart) -- Create a Highlight for this player local highlight = Instance.new("Highlight") highlight.FillTransparency = 1 -- Only outline (no fill) highlight.OutlineTransparency = 0 highlight.OutlineColor = isVisible and Color3.new(1, 0, 0) or Color3.new(0, 1, 0) -- Red if visible, green if not highlight.FillColor = highlight.OutlineColor highlight.Parent = highlightFolder highlight.Adornee = character end end end end -- Toggle with F key UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.F then enabled = not enabled if not enabled then -- Clear all highlights when disabled for _, child in ipairs(highlightFolder:GetChildren()) do child:Destroy() end end end end) -- Update outlines every frame (smooth update) RunService.Heartbeat:Connect(function() updateOutlines() end) -- Handle new players joining Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() updateOutlines() end) end) -- Initial run updateOutlines()