getgenv().sm_config = getgenv().sm_config or {
Enabled = true,
TargetPart = "Head",
FOV = 250,
Color = Color3.fromRGB(0, 255, 255),
Thickness = 1.5,
ShowFOV = true
}
local sm_plrs = game:GetService("Players")
local sm_runS = game:GetService("RunService")
local sm_userInputService = game:GetService("UserInputService")
local sm_localPlayer = sm_plrs.LocalPlayer
local sm_camera = workspace.CurrentCamera
local sm_config = getgenv().sm_config
getgenv().sm_myCharacterInstance = getgenv().sm_myCharacterInstance or nil
local sm_fovCircle = Drawing.new("Circle")
sm_fovCircle.Filled = false
sm_fovCircle.NumSides = 30
sm_fovCircle.Thickness = sm_config.Thickness
sm_fovCircle.Color = sm_config.Color
sm_fovCircle.Visible = sm_config.ShowFOV
local function sm_getClosestPlayer(sm_p9)
local sm_closestTarget = nil
local sm_shortestDistance = sm_config.FOV
local sm_mousePos = sm_userInputService:GetMouseLocation()
local sm_cameraPos = sm_camera.CFrame.Position
if not getgenv().sm_myCharacterInstance or not getgenv().sm_myCharacterInstance.Parent then
local sm_closestDist = math.huge
local sm_detectedChar = nil
local sm_container = workspace:FindFirstChild("Model")
if sm_container then
for sm_i, sm_character in ipairs(sm_container:GetChildren()) do
local sm_head = sm_character:FindFirstChild(sm_config.TargetPart)
if sm_head and sm_head:IsA("BasePart") then
local sm_dist = (sm_head.Position - sm_cameraPos).Magnitude
if sm_dist < sm_closestDist then
sm_closestDist = sm_dist
sm_detectedChar = sm_character
end
end
end
end
if sm_detectedChar and sm_closestDist < 25 then
getgenv().sm_myCharacterInstance = sm_detectedChar
end
end
local sm_container = workspace:FindFirstChild("Model")
if sm_container then
for sm_i, sm_character in ipairs(sm_container:GetChildren()) do
if sm_character == getgenv().sm_myCharacterInstance then
continue
end
if sm_p9 then
if sm_character == sm_p9 or (typeof(sm_p9) == "Instance" and sm_character:IsDescendantOf(sm_p9)) then
continue
end
if typeof(sm_p9) == "table" then
local sm_isIgnored = false
for sm_i, sm_v in pairs(sm_p9) do
if sm_v == sm_character or (typeof(sm_v) == "Instance" and sm_character:IsDescendantOf(sm_v)) then
sm_isIgnored = true
break
end
end
if sm_isIgnored then continue end
end
end
local sm_targetPart = sm_character:FindFirstChild(sm_config.TargetPart)
if sm_targetPart and sm_targetPart:IsA("BasePart") then
local sm_viewportPos, sm_onScreen = sm_camera:WorldToViewportPoint(sm_targetPart.Position)
if sm_viewportPos.Z > 0 then
local sm_distance = (Vector2.new(sm_viewportPos.X, sm_viewportPos.Y) - sm_mousePos).Magnitude
if sm_distance < sm_shortestDistance then
sm_shortestDistance = sm_distance
sm_closestTarget = sm_targetPart
end
end
end
end
end
return sm_closestTarget
end
sm_runS.RenderStepped:Connect(function()
local sm_mousePos = sm_userInputService:GetMouseLocation()
sm_fovCircle.Visible = sm_config.ShowFOV
sm_fovCircle.Radius = sm_config.FOV
sm_fovCircle.Position = sm_mousePos
sm_fovCircle.Color = sm_config.Color
sm_fovCircle.Thickness = sm_config.Thickness
end)
local sm_dischargeFunc = nil
for sm_i, sm_v in pairs(getgc()) do
if typeof(sm_v) == "function" and islclosure(sm_v) then
local sm_constants = getconstants(sm_v)
if table.find(sm_constants, "Bullet_Interaction") and table.find(sm_constants, "ShellTravel") then
sm_dischargeFunc = sm_v
break
end
end
end
if sm_dischargeFunc then
local sm_oldDischarge
sm_oldDischarge = hookfunction(sm_dischargeFunc, newcclosure(function(sm_self, sm_originCFrame, sm_p3, sm_p4, sm_p5, sm_p6, sm_p7, sm_p8, sm_p9, ...)
if sm_config.Enabled then
if sm_p9 and not getgenv().sm_myCharacterInstance then
if typeof(sm_p9) == "Instance" then
if sm_p9:IsA("Model") and sm_p9.Parent == workspace:FindFirstChild("Model") then
getgenv().sm_myCharacterInstance = sm_p9
else
local sm_md = sm_p9:FindFirstAncestorOfClass("Model")
if sm_md and sm_md.Parent == workspace:FindFirstChild("Model") then
getgenv().sm_myCharacterInstance = sm_md
end
end
elseif typeof(sm_p9) == "table" then
for sm_i, sm_v in pairs(sm_p9) do
if typeof(sm_v) == "Instance" then
local sm_md = sm_v:IsA("Model") and sm_v or sm_v:FindFirstAncestorOfClass("Model")
if sm_md and sm_md.Parent == workspace:FindFirstChild("Model") then
getgenv().sm_myCharacterInstance = sm_md
break
end
end
end
end
end
local sm_target = sm_getClosestPlayer(sm_p9)
if sm_target then
sm_originCFrame = CFrame.new(sm_originCFrame.Position, sm_target.Position)
end
end
return sm_oldDischarge(sm_self, sm_originCFrame, sm_p3, sm_p4, sm_p5, sm_p6, sm_p7, sm_p8, sm_p9, ...)
end))
end
Comments
it works, Vouch