local circ = Drawing.new("Circle")
local rs = game:service'RunService'
circ.Radius = 100
circ.Transparency = 0.5
circ.Color = Color3.new(1, 1, 1)
circ.Visible = true
circ.Thickness = 2
circ.Size = 100
rs.RenderStepped:Connect(function()
local uis = game:service'UserInputService'
circ.Position = Vector2.new(uis:GetMouseLocation().X, uis:GetMouseLocation().Y)
end)
print("123")
-- Services
local Players = game:GetService("Players")
local uis = game:GetService("UserInputService")
-- Variables
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
-- Function to find the closest player's head to our cursor/center of screen
local function getClosestPlayerHead()
local closestPlayer = nil
local shortestDistance = circ.Radius
for _, player in pairs(Players:GetPlayers()) do
if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("Head") then
-- Get screen position of the head
local headPos, onScreen = Camera:WorldToViewportPoint(player.Character.Head.Position)
if onScreen then
-- Calculate distance from screen center
local mousePos = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
local distance = (Vector2.new(headPos.X, headPos.Y) - mousePos).Magnitude
if distance < shortestDistance then
closestPlayer = player.Character.Head
shortestDistance = distance
end
end
end
end
return closestPlayer
end
-- Hooking the Index metamethod
local oldIndex
oldIndex = hookmetamethod(game, "__index", function(self, key)
-- Check if the object being indexed is the Camera and the property is CFrame
if self == Camera and key == "CFrame" and not checkcaller() then
-- Check the calling script's name using getfenv or getcallingscript
local traceback = debug.traceback()
if traceback:find("GrabController") and traceback:find("mouseOneClicked") then
local targetHead = getClosestPlayerHead()
if targetHead then
warn(".")
local realCFrame = oldIndex(self, "CFrame")
return CFrame.new(realCFrame.Position, targetHead.Position)
end
end
end
return oldIndex(self, key)
end)
print("Nigga hook.")
Comments
its working thanks