Creating a tracer-like esp?

  1. I want to achieve a Tracer ESP for game objectives for an example, like where theres a tracer on the middle of my screen or middle of my mouse pointing to the game’s objectives.

  2. Issue is I don’t know what kind of math formula do I need to do to make the UI direct from the middle of my screen to the objectives.

  3. I tried a lot of solutions, My math is just not right or I don’t know which formula to use, like what to do with viewportsize/cameratoworldscreen etc

local frame = _G.thatframe 
local db = false
while wait() do
	local a2, withinScreenBounds = workspace.CurrentCamera:WorldToScreenPoint(workspace:WaitForChild('viewcheck').Position)
	local viewport = workspace.CurrentCamera.ViewportSize
	local screenpoint =, a2.Y)
	frame.Position =, viewport.Z/2, 0, viewport.Y/2)
	frame.Size =, viewport.X + a2.X, 0, viewport.Y + a2.Y)


I just need help with what to use.

Here’s what I want to achieve:
Screen Shot 2022-09-09 at 1.29.24 PM

LocalScript → StarterPlayerScripts

local TargetPartName = "HumanoidRootPart"
local GenericHumanoidTargetPartName = TargetPartName	
local LineColor =, 255, 255)
local TeammateLineColor =, 0.25, 1)
local GenericHumanoidLineColor =, 0, 0)
local LineWidth = 2
local DrawTeammates = true
local FindHumanoids = true
local GetLineOrigin = function(Camera)
	return, Camera.ViewportSize.Y*.9)

local Camera = workspace.CurrentCamera
local LineOrigin = nil
	LineOrigin = GetLineOrigin(Camera)
LineOrigin = GetLineOrigin(Camera)

local Gui ="ScreenGui")
Gui.Name = "SnaplineGui"
Gui.Parent = game.Players.LocalPlayer.PlayerGui
local Lines = {}

function Setline(Line, Width, Color, Origin, Destination)
	local Position = (Origin + Destination) / 2
	Line.Position =, Position.X, 0, Position.Y)
	local Length = (Origin - Destination).Magnitude
	Line.BackgroundColor3 = Color
	Line.BorderColor3 = Color
	Line.Size =, Length, 0, Width)
	Line.Rotation = math.deg(math.atan2(Destination.Y - Origin.Y, Destination.X - Origin.X))

	local Targets = {}
	for i, Player in pairs(game.Players:GetPlayers()) do
		if Player == game.Players.LocalPlayer then continue end
		local IsTeammate = game.Players.LocalPlayer.Team ~= nil and Player.Team == game.Players.LocalPlayer.Team
		if not DrawTeammates and IsTeammate then continue end
		local Character = Player.Character
		if not Character then continue end
		local TargetPart = Character:FindFirstChild(TargetPartName)
		if not TargetPart then continue end
		local ScreenPoint, OnScreen = Camera:WorldToScreenPoint(TargetPart.Position)
		if OnScreen then
			table.insert(Targets, {, ScreenPoint.Y), IsTeammate and TeammateLineColor or LineColor})
	if FindHumanoids then
		for _, Obj in pairs(workspace:GetDescendants()) do
			if Obj.ClassName ~= "Humanoid" then continue end
			if game.Players:FindFirstChild(Obj.Parent.Name) then continue end
			local TargetPart = Obj.Parent:FindFirstChild(TargetPartName)
			if not TargetPart then continue end
			local ScreenPoint, OnScreen = Camera:WorldToScreenPoint(TargetPart.Position)
			if OnScreen then
				table.insert(Targets, {, ScreenPoint.Y), GenericHumanoidLineColor})
	if #Targets > #Lines then
		local NewLine ="Frame")
		NewLine.Name = "Snapline"
		NewLine.AnchorPoint =, .5)
		NewLine.Parent = Gui
		table.insert(Lines, NewLine)
	for i, Line in pairs(Lines) do
		local TargetData = Targets[i]
		if not TargetData then
			table.remove(Lines, i)
		Setline(Line, LineWidth, TargetData[2], LineOrigin, TargetData[1])

Thankyou, I just set my script formula as this reference and it works perfectly fine!