Character LocalTransparencyModifier getting set back to 1 after setting it to 0?

I wrote a function for my game that gets called when a player presses “Z”, which should show the body by setting their LocalTransparencyModifier to 0, but for some reason it just turns back to 1???

-- Show body
		model.Humanoid.CameraOffset = module.NoCameraOffset

		for i,v in pairs(model:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") and v.Name ~= "Head" and v ~= model.PrimaryPart then
				if v.Name ~= "Head" and v ~= characterModel.primaryPart then
					--v.Transparency = 0
					v.LocalTransparencyModifier = 0
					print(v.LocalTransparencyModifier)
				end
			end
		end
		module.IsBodyHidden = false
		
		task.wait(2)

		for i,v in pairs(model:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				if v.Name ~= "Head" and v ~= characterModel.primaryPart then
					print(v.LocalTransparencyModifier)
				end
			end
		end
	end

image

this prints the transparencymodifier’s value again after 2 seconds and you can see its 1 again.

I also do not have any other scripts affecting the LocalTransparencyModifier.
image

1 Like

you need to put it in a loop because roblox itself changes it back.

2 Likes

Thanks!, just did this using renderstepped and it worked.

module.HideBodyConnection = RunService.RenderStepped:Connect(function()
			for i,v in pairs(model:GetDescendants()) do
				if v:IsA("BasePart") then
					if v.Name ~= "Head" and v ~= characterModel.primaryPart then
						v.LocalTransparencyModifier = 0
					end
				end
			end
		end)
1 Like

no problem have a nice day.

1 Like

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