Help recreating black censor effect!

Hello! So I was playing this game earlier called “Kill Realistic NPCs Simulator”, what caught my attention was a certain toggeable effect in it that I havent seen before in any game, It was a “Censor dead bodies” toggle, basically what it did was put a black censor bar over the npc’s face whenever it got killed, and this censorship bar changed sizes and shape based on the player’s pov and the direction the npc’s face was looking at in order to Just censor the face, and not the whole head.
(As seen below)

I really want to recreate this in my own game for the creepy and weird effect it gives off, without the dead part ofc, I want the NPCs in my game to all have this censorship alive or not, if that’s possible, I tried multiple time to achieve this effect, but I could never make it change size to accomodate the face.

Help is much appreciated!!!
Note: I’m a VERY young and begginer dev, if you can, please guide me through everything you say/suggest.

first thought was getting the head’s size and just put a cube larger than that.
then i noticed that those rectangles are aligned to the camera view. i think it maybe getting the view aligned bounding box and then put a BillboardGui there

1 Like

I tried doing that with another tutorial I found, couldnt find a way for it to just cover the head or change size/shape depending the pov and orientation

local PlayerGui = game:GetService("Players").LocalPlayer.PlayerGui
local frame = PlayerGui.ScreenGui.Frame
local part: MeshPart = script.Parent.Head

game:GetService("RunService").RenderStepped:Connect(function()
	local camera = workspace.CurrentCamera

	-- Get the bounding box
	local cf = part.CFrame
	local size = part.Size
	local halfSize = size * 0.5

	-- Define the 8 corner points
	local corners = {
		cf * Vector3.new(-halfSize.X, -halfSize.Y, -halfSize.Z),
		cf * Vector3.new(-halfSize.X, -halfSize.Y, halfSize.Z),
		cf * Vector3.new(-halfSize.X, halfSize.Y, -halfSize.Z),
		cf * Vector3.new(-halfSize.X, halfSize.Y, halfSize.Z),
		cf * Vector3.new(halfSize.X, -halfSize.Y, -halfSize.Z),
		cf * Vector3.new(halfSize.X, -halfSize.Y, halfSize.Z),
		cf * Vector3.new(halfSize.X, halfSize.Y, -halfSize.Z),
		cf * Vector3.new(halfSize.X, halfSize.Y, halfSize.Z)
	}

	local minX, minY = math.huge, math.huge
	local maxX, maxY = -math.huge, -math.huge

	-- Project to screen space
	for _, corner in ipairs(corners) do
		local screenPos, onScreen = camera:WorldToScreenPoint(corner)
		if onScreen then
			minX = math.min(minX, screenPos.X)
			minY = math.min(minY, screenPos.Y)
			maxX = math.max(maxX, screenPos.X)
			maxY = math.max(maxY, screenPos.Y)
		end
	end

	-- Screen-aligned bounding box
	local screenBoundingBox = {
		x = minX,
		y = minY,
		width = maxX - minX,
		height = maxY - minY
	}

	frame.Position = UDim2.new(0, screenBoundingBox.x, 0, screenBoundingBox.y)
	frame.Size = UDim2.new(0, screenBoundingBox.width, 0, screenBoundingBox.height)
end)


1 Like

It works perfectly, thank you so much!