Hello, I have a problem with my camera clipping through walls.
Video showcase:
Script I used:
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
RunService.RenderStepped:Connect(function()
local isFirstPerson = (camera.CFrame.Position - head.Position).Magnitude < 1.6
if isFirstPerson then
humanoid.CameraOffset = Vector3.new(0,0,-1.6)
else
humanoid.CameraOffset = Vector3.new(0,0,0)
end
for _, v in character:GetChildren() do
if v:IsA("BasePart") and v ~= head then
v.LocalTransparencyModifier = 0
end
end
end)
I do not have any idea how to fix it.