local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")
local offset = Vector3.new(0, 0, -2)
char.Humanoid.CameraOffset = offset
for i, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "Head" then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
RunService.RenderStepped:Connect(function(step)
local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
local ignoreList = char:GetChildren()
local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
if hit then
char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = offset
end
end)
The issue you are encountering is caused by the fact that the code is setting the LocalTransparencyModifier property of all parts in the character to their Transparency value. This is essentially making all parts transparent, including the layered clothing.
To fix this issue, you should modify the script to only set the LocalTransparencyModifier property for parts that are not part of the layered clothing. You can do this by checking if the part’s parent is the character, and if it is not, then set the LocalTransparencyModifier property.
Here is an example of how you could modify the script to achieve this:
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")
local offset = Vector3.new(0, 0, -2)
char.Humanoid.CameraOffset = offset
for i, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "Head" and v.Parent == char then
v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
v.LocalTransparencyModifier = v.Transparency
end)
v.LocalTransparencyModifier = v.Transparency
end
end
RunService.RenderStepped:Connect(function(step)
local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
local ignoreList = char:GetChildren()
local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
if hit then
char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = offset
end
end)
Note that in this modified script, we added a check to make sure that the part’s parent is equal to the character, which excludes parts that are part of the layered clothing.