-- Opponent Team ESP with distance-based scaling (Final Fixed Version) local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Teams = game:GetService("Teams") local CurrentCamera = workspace.CurrentCamera local LocalPlayer = Players.LocalPlayer local FOV_OFFSET = Vector3.new(0, 3, 0) local espFrames = {} -- [player] = TextLabel -- Script I made with chat gpt in like 10 mins so enjoy made by roblox "Dereks_altz" -- Enjoy! -- Scaling config local MAX_DISTANCE = 100000 -- farthest distance considered local MIN_SCALE = 0.5 -- smallest text scale local MAX_SCALE = 2.0 -- largest text scale -- Create GUI local screenGui = Instance.new("ScreenGui") screenGui.Name = "OpponentTeamESP" screenGui.ResetOnSpawn = false screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") -- Create a TextLabel for a player local function CreateTeamLabel(player, teamName, color) local label = Instance.new("TextLabel") label.Size = UDim2.new(0, 120, 0, 24) label.BackgroundTransparency = 1 label.TextColor3 = color or Color3.new(1, 1, 1) label.Text = teamName or "Neutral" label.TextScaled = true label.Font = Enum.Font.SourceSansBold label.Parent = screenGui return label end -- Safely get player's team name local function GetPlayerTeamName(player) -- Custom attribute support local attrTeam = player:GetAttribute("teamname") if attrTeam and attrTeam ~= "" then return attrTeam end -- Fallback to Roblox Team property if player.Team then return player.Team.Name end -- No team return nil end -- Safely get team color local function GetTeamColorFromService(teamName) if not teamName then return Color3.new(1, 1, 1) end for _, team in ipairs(Teams:GetTeams()) do if team.Name == teamName then return team.TeamColor.Color end end return Color3.new(1, 1, 1) end local function WorldToScreen(part) if not part then return nil end local pos, onScreen = CurrentCamera:WorldToViewportPoint(part.Position + FOV_OFFSET) if onScreen then return Vector2.new(pos.X, pos.Y), pos.Z end end -- Main ESP loop local function UpdateESP() for _, player in ipairs(Players:GetPlayers()) do if player ~= LocalPlayer then local char = player.Character if char then local head = char:FindFirstChild("Head") if head then local teamName = GetPlayerTeamName(player) local localTeam = GetPlayerTeamName(LocalPlayer) -- Only show ESP for opponents, or neutral players if local has a team if teamName and (not localTeam or teamName ~= localTeam) then local color = GetTeamColorFromService(teamName) if not espFrames[player] then espFrames[player] = CreateTeamLabel(player, teamName, color) end local label = espFrames[player] label.Text = teamName or "Neutral" label.TextColor3 = color local screenPos, depth = WorldToScreen(head) if screenPos then label.Position = UDim2.new(0, screenPos.X - 60, 0, screenPos.Y - 12) label.Visible = true -- Distance-based scaling local distance = (head.Position - CurrentCamera.CFrame.Position).Magnitude local scaleFactor = math.clamp(MAX_DISTANCE / distance, MIN_SCALE, MAX_SCALE) label.TextSize = math.floor(18 * scaleFactor) else label.Visible = false end else if espFrames[player] then espFrames[player].Visible = false end end end end end end end -- Handle new players and respawns local function HandleCharacter(player) local function CreateOrUpdateESP() task.wait(1) -- ensure character fully loads local teamName = GetPlayerTeamName(player) local color = GetTeamColorFromService(teamName) -- Always refresh label if espFrames[player] then espFrames[player]:Destroy() end espFrames[player] = CreateTeamLabel(player, teamName, color) end if player.Character then CreateOrUpdateESP() end player.CharacterAdded:Connect(CreateOrUpdateESP) end -- Initialize existing players for _, player in ipairs(Players:GetPlayers()) do HandleCharacter(player) end -- Detect join/leave Players.PlayerAdded:Connect(HandleCharacter) Players.PlayerRemoving:Connect(function(player) if espFrames[player] then espFrames[player]:Destroy() espFrames[player] = nil end end) -- Update every frame RunService.RenderStepped:Connect(UpdateESP)