Hitbox And Lock
Key RequiredUniversal

Hitbox And Lock

Universal ScriptVekosScriptsVekosScripts 1.3K views 11 executesUpdated Jul 29, 2025
Unrated
00
Lua Script•101 lines (2915 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local LocalPlayer = Players.LocalPlayer

local FOV = 100
local MaxDistance = 100
local AimPart = "HumanoidRootPart"
local Target = nil
local FakePart, Dot = nil, nil

local function clearVisuals()
	if FakePart then FakePart:Destroy() end
	if Dot then Dot:Destroy() end
end

local function createVisuals(targetChar)
	clearVisuals()

	local part = targetChar:FindFirstChild(AimPart)
	if not part then return end

	FakePart = Instance.new("BoxHandleAdornment")
	FakePart.Size = Vector3.new(24, 24, 24)
	FakePart.Adornee = part
	FakePart.AlwaysOnTop = true
	FakePart.ZIndex = 10
	FakePart.Color3 = Color3.new(0, 0, 0)
	FakePart.Transparency = 0.6
	FakePart.Parent = game.CoreGui

	Dot = Instance.new("SphereHandleAdornment")
	Dot.Radius = 1.5 -- increased size
	Dot.Adornee = part
	Dot.AlwaysOnTop = true
	Dot.ZIndex = 11
	Dot.Color3 = Color3.new(1, 1, 1)
	Dot.Transparency = 0
	Dot.Parent = game.CoreGui
end

local function getClosestTarget()
	local closest, shortestDist = nil, math.huge

	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild(AimPart) then
			local part = player.Character[AimPart]
			local screenPos, onScreen = Camera:WorldToViewportPoint(part.Position)
			local dist2D = (Vector2.new(screenPos.X, screenPos.Y) - Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)).Magnitude
			local dist3D = (part.Position - Camera.CFrame.Position).Magnitude

			local rayParams = RaycastParams.new()
			rayParams.FilterType = Enum.RaycastFilterType.Blacklist
			rayParams.FilterDescendantsInstances = {LocalPlayer.Character}

			local ray = workspace:Raycast(Camera.CFrame.Position, (part.Position - Camera.CFrame.Position).Unit * 500, rayParams)

			if onScreen and dist2D <= FOV and dist3D <= MaxDistance and ray and ray.Instance and ray.Instance:IsDescendantOf(player.Character) then
				if dist2D < shortestDist then
					shortestDist = dist2D
					closest = player
				end
			end
		end
	end

	return closest
end

local function updateDot(part)
	local t = tick()
	local radius = 12
	local orbitSpeed = 2

	local x = math.cos(t * orbitSpeed) * radius
	local z = math.sin(t * orbitSpeed) * radius
	local y = 0

	local offset = Vector3.new(x, y, z)
	if Dot then
		Dot.CFrame = part.CFrame:ToWorldSpace(CFrame.new(offset))
	end
end

RunService.RenderStepped:Connect(function()
	local newTarget = getClosestTarget()

	if newTarget ~= Target then
		Target = newTarget
		clearVisuals()
		if Target and Target.Character then
			createVisuals(Target.Character)
		end
	end

	if Target and Target.Character and Target.Character:FindFirstChild(AimPart) then
		local part = Target.Character[AimPart]
		Camera.CFrame = CFrame.new(Camera.CFrame.Position, part.Position)
		updateDot(part)
	end
end)

Features & Information

Good

Community Comments (2)

SyrexhubOfficialSyrexhubOfficialJul 29, 2025

What/which game is this script for or is universal like it says

VekosScriptsVekosScriptsJul 30, 2025

This is universal!

More Scripts for Universal Scripts