LocalTransparencyModifier not working?

I have this script right

local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local Camera = game.Workspace.CurrentCamera

for i, part in pairs(Character:GetChildren()) do
	if part:IsA("BasePart") then
		part.LocalTransparencyModifier = 0
	end
end


game:GetService("RunService").RenderStepped:Connect(function ()
	Humanoid.CameraOffset = Vector3.new(0, 0, -0.8)
	Camera.FieldOfView = 85
end)

for some reason it doesnt make the parts localTransparency == 0?

how could i fix this

1 Like

when you zoom in the transparency modifier gets changed again, so changing it one time won’t keep it that way forever

put it inside of the loop
or trigger it after the player zooms in if its too inefficient

local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local Camera = game.Workspace.CurrentCamera

game:GetService("RunService").RenderStepped:Connect(function ()
	Humanoid.CameraOffset = Vector3.new(0, 0, -0.8)
	Camera.FieldOfView = 85

     for i, part in pairs(Character:GetChildren()) do
	     if part:IsA("BasePart") then
	      	 part.LocalTransparencyModifier = 0
	     end
     end

end)
2 Likes

this is inefficient, to a degree.

what i would do is modify the PlayerModule.CameraModule.TransparencyController and comment out line 220.

-- child.LocalTransparencyModifier = transparency
2 Likes

Modifying transparency in RenderStepped is often needed due to Roblox changing the values when the camera is close to the head (seems to be the trigger, as I never set cameras to anything other than scriptable or custom).

If you have a lot of parts in your character that you want to modify, or just want something more effecient, you could clone the parts and parent them outside of the character, and then make the parts inside of the character invisibe. That way you can still identify what the character has in it.

1 Like

That’s nice. I guess you then have to set the transparency modifier to 1 for the parts you want invisible, but certainly nicer.

2 Likes

edit: actually, i misunderstood. yes, you would, but it is the same for any other method.

1 Like

i have the player locked in first person, and I don’t want to put it in RenderStepped because I have viewmodel local scripts controlling it.

so i only want it to run once.

has anyone found a way to get this working?

how would i modify it/ find it? where do i go?

Play the game in studio, go to your player’s scripts, and copy the player module. Stop the game, then paste the player module into starter player scripts and do what the original comment said from there

1 Like

thats what i did, I’ve updated the script since then it still only works like 60% of the time though

local TransparencyController = game.ReplicatedStorage.BasePlayerScripts.TransparencyController
local plr = script.Parent 

local PlayerModule = plr:FindFirstChild("PlayerModule")
local CameraModule = PlayerModule:FindFirstChild("CameraModule")
local TransparencyControllerInScript = CameraModule:FindFirstChild("TransparencyController")

if TransparencyControllerInScript then
	local TC_Parent = TransparencyControllerInScript.Parent
	TransparencyControllerInScript:Destroy()

	TransparencyController.Parent = TC_Parent
	print(TransparencyController.Parent)
	print(TransparencyControllerInScript)
end

prints the correct parent and correct script 100% of the time but for some reason sometimes the players character will still be invisible, can’t figure out why.

I think a more robust method would be to just check whenever the LocalTransparencyModifier gets changed, and to reset it when it does. e.g.:

local IGNORED_BODY_PARTS = {'Head'} -- Change


for _, bodyPart in character:GetChildren() do
	if (bodyPart:IsA('BasePart')) and (not table.find(IGNORED_BODY_PARTS, bodyPart.Name)) then
		bodyPart:GetPropertyChangedSignal('LocalTransparencyModifier'):Connect(function()
			bodyPart.LocalTransparencyModifier = 0
		end)

		bodyPart.LocalTransparencyModifier = 0
	end
end
1 Like

that would work great but i have a viewmodel and and a local script that makes the left arm and right arm Transparent with the localtransparencymodifier, how could i make this script not effect the others usin localtransparencymodifier

Nevermind, got it fixed up:

local IGNORED_BODY_PARTS = {'Head'} -- Change
local character = script.Parent


for _, bodyPart in character:GetChildren() do
	if (bodyPart:IsA('BasePart')) and (not table.find(IGNORED_BODY_PARTS, bodyPart.Name)) then
		bodyPart:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			if character:FindFirstChild("ViewportHands") then
				if bodyPart.Name == "Left Arm" or bodyPart.Name == "Right Arm" then
					bodyPart.LocalTransparencyModifier = 1
					else
					bodyPart.LocalTransparencyModifier = 0
				end
				else

				bodyPart.LocalTransparencyModifier = 0
			end
		end)

		bodyPart.LocalTransparencyModifier = 0
	end
end

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