Player Transparency Controller

Transparency Controller is one of the default module scripts under Camera Module, under the Player Module. It controls the transparency of the player model when the camera is zoomed in. Thing is, roblox nowdays, for some reason, only lets you access the Control Module and even though a function for accessing the Camera Module exists, the module always returns an empty table (this is intended related dev forum post).
That doesnt mean someone cannot see how the default Transparency Controller works, looking into it i found a property named LocalTransparencyModifier of base parts, …
This is key to how the Transparency Controllers work, this property is not replicated (only the local client can see it) and it doesnt change the actual transparency! Meaning transparent parts will stay transparent and non-transparent parts will get transparent!

This paired with some overridable tween setup gets you, a small Transparency Controller you can put in any local script or just have it a standalone module (by making the tween_char_transparency function a module.tween_char_transparency).
Note: you have full control over what transparency the character is, the camera zoom level does not effect it BUT the default transparency controller can still override your LocalTransparencyModifier property values.

local tween_service = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer

-- all classes with the LocalTransparencyModifier property (same as in the default Transparency Controller)
local CHAR_TRANSPARENCY_MODIFIER_CLASSES = {
	"BasePart",
	"Decal",
	"Beam",
	"ParticleEmitter",
	"Trail",
	"Fire",
	"Smoke",
	"Sparkles",
	"Explosion"
}
local char_transparency_tweens = {} -- registry of playing tweens so they can be overriden
function tween_char_transparency(end_transparency, tween_info)
	-- in case the player just respawned or is not spawned yet, wait for the character
	repeat task.wait() until player.Character ~= nil
	
	-- cancel previouse running tweens (if any)
	for _, tween in char_transparency_tweens do
		if tween.PlaybackState == Enum.PlaybackState.Playing then tween:Cancel() end
	end
	table.clear(char_transparency_tweens)
	-- if the transparency modifier is already correct do not re-tween
	if player.Character.HumanoidRootPart.LocalTransparencyModifier == end_transparency then return end
	
	for _, desc in player.Character:GetDescendants() do
		-- do not tween descendants of tools
		if desc:FindFirstAncestorOfClass("Tool") then continue end
		-- check if the descendant is of any class in the class table
		local is_a = false
		for _, class in CHAR_TRANSPARENCY_MODIFIER_CLASSES do
			if desc:IsA(class) then is_a = true break end
		end
		if not is_a then continue end
		
		-- tween!
		local tween = tween_service:Create(desc, tween_info, {LocalTransparencyModifier = end_transparency})
		tween:Play()
		table.insert(char_transparency_tweens, tween)
	end
end

^ added pleanty of comments for explanation

3 Likes