You are on page 1of 2

local Targets = {}

local FieldOfView = 500


local Dynamic = true
local Team = false
local Size = UDim2.new(0, 18, 0, 21)
local Color = Color3.fromRGB(255, 255, 255)

local Players = game:GetService("Players")


local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

local ScreenGui = Instance.new("ScreenGui", game:GetService("CoreGui"))


local Folder = Instance.new("Folder", ScreenGui)

local function Target(Player)


local ImageLabel = Instance.new("ImageLabel", Folder)
ImageLabel.Name = "ImageLabel"
ImageLabel.ImageColor3 = Color
ImageLabel.BackgroundTransparency = 1
ImageLabel.Image = "http://www.roblox.com/asset/?id=6954524255"

Targets[Player.Name] = {
Player = Player,
Indicator = ImageLabel
}
end

for _, Player in next, Players:GetPlayers() do


if Player ~= LocalPlayer then
Target(Player)
end
end

Players.PlayerAdded:Connect(function(Player)
Target(Player)
end)

game:GetService("RunService").RenderStepped:connect(function()
for Name, Target in next, Targets do
if Target.Indicator then
local Indicator = Target.Indicator
if Players:FindFirstChild(Name) then
Target = Target.Player

if LocalPlayer.Character and Target.Character and


Target.Character:FindFirstChild("HumanoidRootPart") then
local Character = Target.Character
local WorldPosition = Character.HumanoidRootPart.Position
local CameraVector = Camera.CFrame.Position
local LookVector = Camera.CFrame.LookVector
local ProjectVector = (WorldPosition - CameraVector)
local Dot = LookVector:Dot(ProjectVector)

if Dot <= 0 then


WorldPosition = (CameraVector + (ProjectVector -
((LookVector * Dot) * 1.01)))
end

local ScreenPosition, Visible =


Camera:WorldToScreenPoint(WorldPosition)
local RayCast = workspace:FindPartOnRay(Ray.new(CameraVector,
((WorldPosition - CameraVector).Unit * 500)), LocalPlayer.Character, false, false)

if (Visible and RayCast and not


RayCast:IsDescendantOf(Character)) or not Visible then
local Center = (ScreenGui.AbsoluteSize / 2)
local Direction = (Vector2.new(ScreenPosition.X,
ScreenPosition.Y) - Center).Unit
local Radian = math.atan2(Direction.X, Direction.Y)
local Angle = (((math.pi * 2) / FieldOfView) * Radian)
local ClampedPosition = (Center + (Direction *
math.min(math.abs(((Center.Y - FieldOfView) / math.sin(Angle)) * FieldOfView),
math.abs((Center.X - FieldOfView) / (math.cos(Angle)) / 2))))

Indicator.Position = UDim2.new(0, (ClampedPosition.X -


(Indicator.Size.X.Offset / 2)), 0, ((ClampedPosition.Y - (Indicator.Size.Y.Offset /
2) - 15)))
Indicator.Rotation = (-math.deg(Radian) + 180)

if Dynamic then
local Magnitude = ((1 /
(LocalPlayer.Character.HumanoidRootPart.Position - WorldPosition).Magnitude) *
1000)

if Magnitude > 18 then


Magnitude = 18
elseif Magnitude < 11 then
Magnitude = 11
end

Indicator.Size = UDim2.new(0, Magnitude, 0, (Magnitude +


3))
else
Indicator.Size = Size
end

Indicator.Visible = true
else
Indicator.Visible = false
end
else
Indicator.Visible = false
end

if Team and Target.Team == LocalPlayer.Team then


Indicator.Visible = false
end
else
Indicator:Destroy()
end
end
end
end)

You might also like