Head shadow not showing in first person

Hi,

I’m making a first person camera and I don’t like how when I change the head local transparency it hides the shadow. I would also like accessories like hair to show. How do I do this?

local function updateCharacter(character: Model)
    -- just a check cuz this goes in runservice
	if Character:FindFirstChild("Head") and Character:FindFirstChild("Head").LocalTransparencyModifier == 1 then
		return
	end

	for _, instance in pairs(character:GetChildren()) do
		if instance.Name == "Head" and instance:IsA("BasePart") then
			instance.LocalTransparencyModifier = 1

			if instance:FindFirstChildOfClass("Decal") then
				local Decal = instance:FindFirstChildOfClass("Decal") :: Decal
				Decal.LocalTransparencyModifier = 1
			end
		end

		if instance:IsA("Accessory") or instance:IsA("Hat") then
			if not instance:FindFirstChild("Handle") then
				continue
			end

			local Handle = instance:FindFirstChild("Handle") :: BasePart

			Handle.LocalTransparencyModifier = 1
		end
	end
end

Theres two neat little tricks I know that you can use to forcibly render shadows with transparent parts:

First method:

  1. Set the part’s transparency to -inf (you can type -9999999…etc. until the property shows as -inf)
  2. Set the part’s material to ForceField
  3. Shadow should render but part won’t

Note: If I remember correctly, this method does not work for mobile devices, as they use a different rendering engine that lacks this behavior.

Second method:

  1. Set the part’s transparency to inf
  2. Set the part’s material to anything except glass
  3. Add a Highlight to the part
  4. Shadow should render but part won’t

Note: This method uses a Highlight instance, which can be problematic if your game uses many already, as they have a rendering limit of 31 even if the Highlight isn’t visible.

I’d recommend:

  • Making a clone of the head
  • Disabling all collisions and querying properties
  • Renaming it to something like “Shadow” to prevent conflicts with internal humanoid code
  • Welding this clone to the existing head

If you want to keep hair visible, you can check the accessory’s AccessoryType property and make sure it doesn’t equal Enum.AccessoryType.Hair

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.