-- Camera Follow with UI, FOV Circle, Distance Display -- Safe for own game / spectator mode local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera -- SETTINGS local ENABLED = false local FOV_RADIUS = 180 -- pixels local SMOOTHNESS = 0.12 local MAX_DISTANCE = 500 -- UI local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui")) gui.Name = "CameraFollowUI" -- Toggle Button local toggle = Instance.new("TextButton", gui) toggle.Size = UDim2.new(0,160,0,40) toggle.Position = UDim2.new(0,20,0,20) toggle.Text = "Camera Follow: OFF" toggle.BackgroundColor3 = Color3.fromRGB(30,30,30) toggle.TextColor3 = Color3.fromRGB(255,255,255) toggle.BorderSizePixel = 0 toggle.TextScaled = true toggle.Font = Enum.Font.GothamBold toggle.MouseButton1Click:Connect(function() ENABLED = not ENABLED toggle.Text = ENABLED and "Camera Follow: ON" or "Camera Follow: OFF" end) -- Distance Label local distanceLabel = Instance.new("TextLabel", gui) distanceLabel.Size = UDim2.new(0,200,0,30) distanceLabel.Position = UDim2.new(0.5,-100,0.5,80) distanceLabel.BackgroundTransparency = 1 distanceLabel.TextColor3 = Color3.fromRGB(255,255,255) distanceLabel.TextScaled = true distanceLabel.Font = Enum.Font.GothamBold distanceLabel.Text = "" -- FOV Circle local circle = Instance.new("Frame", gui) circle.Size = UDim2.new(0,FOV_RADIUS*2,0,FOV_RADIUS*2) circle.Position = UDim2.new(0.5,-FOV_RADIUS,0.5,-FOV_RADIUS) circle.BackgroundTransparency = 1 circle.BorderSizePixel = 0 local uiCorner = Instance.new("UICorner", circle) uiCorner.CornerRadius = UDim.new(1,0) local stroke = Instance.new("UIStroke", circle) stroke.Thickness = 2 stroke.Color = Color3.fromRGB(0,170,255) stroke.Transparency = 0.2 -- Find closest visible player in FOV local function getTarget() local closest, closestDist = nil, math.huge local center = Vector2.new(camera.ViewportSize.X/2, camera.ViewportSize.Y/2) for _, plr in ipairs(Players:GetPlayers()) do if plr ~= player and plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then local hrp = plr.Character.HumanoidRootPart local screenPos, visible = camera:WorldToViewportPoint(hrp.Position) if visible and screenPos.Z > 0 then local screenDist = (Vector2.new(screenPos.X, screenPos.Y) - center).Magnitude local worldDist = (hrp.Position - camera.CFrame.Position).Magnitude if screenDist <= FOV_RADIUS and worldDist <= MAX_DISTANCE and screenDist < closestDist then closestDist = screenDist closest = hrp end end end end return closest end -- Camera update RunService.RenderStepped:Connect(function() if not ENABLED then distanceLabel.Text = "" return end local target = getTarget() if target then local camPos = camera.CFrame.Position camera.CFrame = camera.CFrame:Lerp( CFrame.new(camPos, target.Position), SMOOTHNESS ) local studs = math.floor((target.Position - camPos).Magnitude) distanceLabel.Text = studs .. " studs" else distanceLabel.Text = "" end end)