FPS View - Invisible Accessories

Hello devs, I would like to create a FPS view : I can see my arms, legs etc. but I don’t see Accessories, how can I ? I tried to add a loop for Accessories but does not fix the problem.

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 2.5, -1.5)

for i, v in pairs(char:GetChildren()) do
	if v:IsA("BasePart") or v:IsA("MeshPart") then
		v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			v.LocalTransparencyModifier = v.Transparency
		end)

		v.LocalTransparencyModifier = v.Transparency
	elseif v:IsA("Accessory") then 
		for i2, v2 in pairs(v:GetChildren()) do 
			v2:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
				v2.LocalTransparencyModifier = v2.Transparency
			end)

			v2.LocalTransparencyModifier = v2.Transparency
		end
	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 = Vector3.new(0, 2.5, -1.5)
	end
end)
2 Likes

The code seems to work fine in an empty baseplate. Are you sure there isn’t another problem causing your code to not work?

2 Likes

I use child added and remove to refresh the loop to set the local transparency.

1 Like

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