Hitbox visualizer
Key RequiredUniversal

Hitbox visualizer

Universal Scriptreynaldolefodeaxdloreynaldolefodeaxdlo 2.3K views 290 executesUpdated Dec 11, 2025
5.0/ 5(2 votes)
20100% Positive
Lua Script•146 lines (3349 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
local LP = Players.LocalPlayer

local TRANSPARENCY = 0.35
local HITBOX_COLOR = Color3.fromRGB(255, 0, 0)
local LOCAL_COLOR = Color3.fromRGB(0, 255, 0)
local HITBOX_SIZE = Vector3.new(2.5, 3.5, 1)
local PING_ESTIMATE = 0.0979
local MAX_HISTORY_SECONDS = 2.0
local SMOOTH_LERP = 0.9
local SHOW_LOCAL_HITBOX = true

local history = {}
local serverVisualizer = nil
local localVisualizer = nil
local hbConn = nil

local function log(msg)
	print("[HitboxViz] " .. msg)
end

local function createHitboxPart(name, color)
	local p = Instance.new("Part")
	p.Name = name
	p.Size = HITBOX_SIZE
	p.Anchored = true
	p.CanCollide = false
	p.Locked = true
	p.Material = Enum.Material.ForceField
	p.Color = color
	p.Transparency = TRANSPARENCY

	local cam = workspace.CurrentCamera
	if cam then
		p.Parent = cam
	else
		p.Parent = workspace
	end

	return p
end

local function cleanup()
	if hbConn then
		hbConn:Disconnect()
		hbConn = nil
	end
	if serverVisualizer then
		serverVisualizer:Destroy()
		serverVisualizer = nil
	end
	if localVisualizer then
		localVisualizer:Destroy()
		localVisualizer = nil
	end
	history = {}
end

local function findEntryAtTime(targetTime)
	for i = #history, 1, -1 do
		if history[i].t <= targetTime then
			return history[i]
		end
	end
	return nil
end

local function startVisualizer(character)
	cleanup()
	log("Iniciando visualizador...")

	local hrp = character:FindFirstChild("HumanoidRootPart")
		or character:FindFirstChild("UpperTorso")
		or character:FindFirstChild("Torso")

	if not hrp then
		log("HRP/Torso not found.")
		return
	end

	-- asegurar cámara
	repeat task.wait() until workspace.CurrentCamera

	serverVisualizer = createHitboxPart("Server_HitboxViz", HITBOX_COLOR)

	if SHOW_LOCAL_HITBOX then
		localVisualizer = createHitboxPart("Local_HitboxViz", LOCAL_COLOR)
		localVisualizer.Transparency = TRANSPARENCY * 0.6
	end

	local alpha = 1 - SMOOTH_LERP
	if alpha < 0 then alpha = 0 end
	if alpha > 1 then alpha = 1 end

	hbConn = RunService.Heartbeat:Connect(function()
		if not hrp or not hrp.Parent then
			cleanup()
			return
		end

		local now = os.clock()
		table.insert(history, { t = now, cframe = hrp.CFrame })

		while #history > 1 and (now - history[1].t) > MAX_HISTORY_SECONDS do
			table.remove(history, 1)
		end

		local targetTime = now - PING_ESTIMATE
		local entry = findEntryAtTime(targetTime)

		local targetCFrame = entry and entry.cframe
			or (history[1] and history[1].cframe)
			or hrp.CFrame

		if serverVisualizer and serverVisualizer.Parent then
			serverVisualizer.CFrame = serverVisualizer.CFrame:Lerp(targetCFrame, alpha)
			serverVisualizer.Size = HITBOX_SIZE
		end

		if localVisualizer and localVisualizer.Parent then
			localVisualizer.CFrame = localVisualizer.CFrame:Lerp(hrp.CFrame, alpha)
			localVisualizer.Size = HITBOX_SIZE
		end
	end)

	log("Visualizer Enabled.")
end

-- Inicialización
if LP.Character and LP.Character.Parent then
	task.delay(0.2, function()
		startVisualizer(LP.Character)
	end)
end

LP.CharacterAdded:Connect(function(ch)
	task.wait(0.5)
	startVisualizer(ch)
end)

StarterGui:SetCore("ChatMakeSystemMessage", {
	Text = "[Server Hitbox] Enabled — Red = server view approx.",
	Color = Color3.fromRGB(255,0,0),
})

Features & Information

By chat gpt lol (u need to change the "local PING_ESTIMATE = 0.0979" by your average ping, try to see it with Shift + F3 Your real ping. like 0.12 = 120 ms) The red box one its the server hitbox The green box its the hitbox client before the server confirms before the ping arrives
#Hitbox#Visual#Ping

Community Comments (2)

Matukex_StudioMatukex_StudioDec 11, 2025

Buen chatgpt Hermano. no pudiste eliminar los comentarios almenos?

Replying to @Matukex_Studio

@Matukex_Studio ya lo hice

More Scripts for Universal Scripts