local p=game:GetService("\080\108\097\121\101\114\115")local J=game:GetService("\082\117\110\083\101\114\118\105\099\101")local v=Vector3.new()local A=p.LocalPlayer function Update()local p=A.Character local J=workspace.CurrentCamera if not p then return end local d=p:WaitForChild("\072\117\109\097\110\111\105\100")local g=p:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")local X=p:WaitForChild("\072\101\097\100")for p,J in ipairs(p:GetChildren())do if J:IsA("\066\097\115\101\080\097\114\116")then if J.Name~="\072\101\097\100"then J.LocalTransparencyModifier=0 end elseif J:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")then local p=J:FindFirstChild("\072\097\110\100\108\101")if p then local J=(p:FindFirstChild("\072\097\116\065\116\116\097\099\104\109\101\110\116")or p:FindFirstChild("\072\097\105\114\065\116\116\097\099\104\109\101\110\116")or p:FindFirstChild("\070\097\099\101\065\116\116\097\099\104\109\101\110\116")or p:FindFirstChild("\078\101\099\107\065\116\116\097\099\104\109\101\110\116"))~=nil if J then if ViewAccessories and ViewHeadAccessories then p.LocalTransparencyModifier=0 end else if ViewAccessories then p.LocalTransparencyModifier=0 end end end end end if RealisticView and A.CameraMode==Enum.CameraMode.LockFirstPerson or(p:WaitForChild("\072\101\097\100")).LocalTransparencyModifier==1 then local A=J.CFrame local M=J.CFrame*CFrame.new(0,0,-1)local t=(A.Y-M.Y)*-1 local D=0 local V=0 local O=1.5 local c=Vector3.new(0,0,math.min(t-D,0))local P=p:FindFirstChild("\085\112\112\101\114\084\111\114\115\111")if P then local p=(g.CFrame:toObjectSpace(X.CFrame)).p v=c+(p-Vector3.new(0,2,0))else v=c end d.CameraOffset=v else d.CameraOffset=Vector3.new()end end if AutoLockFirstPerson then A.CameraMode=Enum.CameraMode.LockFirstPerson end J.RenderStepped:Connect(Update)

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local Offset = Vector3.new()

local Player = Players.LocalPlayer

function Update()
	local Character = Player.Character --I'll have this here, should the script be in StarterPlayerScripts
	local Camera = workspace.CurrentCamera --In case they delete the camera or something.
	if not Character then
		return
	end
	
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	local Head = Character:WaitForChild("Head")
	
	for Index, Item in ipairs(Character:GetChildren()) do
		if Item:IsA("BasePart") then
			if Item.Name ~= "Head" then
				Item.LocalTransparencyModifier = 0
			end
		elseif Item:IsA("Accoutrement") then
			local Handle = Item:FindFirstChild("Handle")
			if Handle then
				local ConnectedToHead = (Handle:FindFirstChild("HatAttachment") or Handle:FindFirstChild("HairAttachment") or Handle:FindFirstChild("FaceAttachment") or Handle:FindFirstChild("NeckAttachment")) ~= nil
				if ConnectedToHead then
					if ViewAccessories and ViewHeadAccessories then
						Handle.LocalTransparencyModifier = 0
					end
				else
					if ViewAccessories then
						Handle.LocalTransparencyModifier = 0
					end
				end
			end
		end
	end
	
	if (RealisticView and Player.CameraMode == Enum.CameraMode.LockFirstPerson)
		or (Character:WaitForChild("Head").LocalTransparencyModifier == 1) then
		--Above: Adding [or (Character:WaitForChild("Head").LocalTransparencyModifier == 1)] will make it so we can
		--detect if the player is in first-person
		local Origin = Camera.CFrame
		local Out = Camera.CFrame * CFrame.new(0, 0, -1)
		local Y_Diff = (Origin.Y - Out.Y) * -1
		local Z_Diff = 0
		local Extra_X = 0
		local Extra_Y = 1.5
		
		local Camera_Offset = Vector3.new(0, 0, math.min(Y_Diff - Z_Diff, 0))
		
		--Update #2: R15 offsets cause issues with this code block. This next one will fix that.
		local UpperTorso = Character:FindFirstChild("UpperTorso")
		if UpperTorso then
			local OffsetVal = HumanoidRootPart.CFrame:toObjectSpace(Head.CFrame).p
			Offset = Camera_Offset + (OffsetVal - Vector3.new(0, 2, 0))
		else
			Offset = Camera_Offset
		end
		
		Humanoid.CameraOffset = Offset
	else
		Humanoid.CameraOffset = Vector3.new()
	end
end

if AutoLockFirstPerson then
	Player.CameraMode = Enum.CameraMode.LockFirstPerson
end

RunService.RenderStepped:Connect(Update)
