function FpsCamera.OnRotationTypeChanged(s)local k=workspace.CurrentCamera local r=k and k.CameraSubject if r and r:IsA("\072\117\109\097\110\111\105\100")then local z=UserGameSettings.RotationType if z==Enum.RotationType.CameraRelative then r.AutoRotate=false RunService:BindToRenderStep("\070\112\115\067\097\109\101\114\097",1000,function(z)if r.AutoRotate or not r:IsDescendantOf(game)or r.SeatPart and r.SeatPart:IsA("\086\101\104\105\099\108\101\083\101\097\116")then RunService:UnbindFromRenderStep("\070\112\115\067\097\109\101\114\097")return end if k.CameraType.Name=="\083\099\114\105\112\116\097\098\108\101"then return end local t=r.RootPart local w=t and t:IsGrounded()if t and not w then local w=r:GetState()local T=true if s.InvalidRotationStates[w.Name]then T=false end if r.Sit and r.SeatPart then local s=t:GetRootPart()if s~=t then T=false end end if T then local s=t.Position local r=math.min(.2,(z*40)/3)local w=k.CFrame.LookVector w=(w*XZ_VECTOR3).Unit local T=CFrame.new(s,s+w)t.CFrame=t.CFrame:Lerp(T,r)end end if s:IsInFirstPerson()then local z=k.CFrame local t,w=s:GetSubjectPosition(r)if t then local s=t-z.Position z+=s k.CFrame=z k.Focus+=s end local T=s:GetShadowAngle()local d=z.LookVector:Dot(T)if d<0 then for s,k in pairs(s.HeadMirrors)do k.CFrame=s.CFrame+T*9 end end s.MirrorBin.Parent=d<0 and k or nil else s.MirrorBin.Parent=nil end end)else r.AutoRotate=true s.MirrorBin.Parent=nil end end end


function FpsCamera:OnRotationTypeChanged()
	local camera = workspace.CurrentCamera
	local subject = camera and camera.CameraSubject
	
	if subject and subject:IsA("Humanoid") then
		local rotationType = UserGameSettings.RotationType
	
		if rotationType == Enum.RotationType.CameraRelative then
			subject.AutoRotate = false
			
			RunService:BindToRenderStep("FpsCamera", 1000, function (delta)
				if subject.AutoRotate or not subject:IsDescendantOf(game) or (subject.SeatPart and subject.SeatPart:IsA("VehicleSeat")) then
					RunService:UnbindFromRenderStep("FpsCamera")
					return
				end

				if camera.CameraType.Name == "Scriptable" then
					return
				end
				
				local rootPart = subject.RootPart
				local isGrounded = rootPart and rootPart:IsGrounded()
				
				if rootPart and not isGrounded then
					local state = subject:GetState()
					local canRotate = true

					if self.InvalidRotationStates[state.Name] then
						canRotate = false
					end

					if subject.Sit and subject.SeatPart then
						local root = rootPart:GetRootPart()

						if root ~= rootPart then
							canRotate = false
						end
					end

					if canRotate then
						local pos = rootPart.Position
						local step = math.min(0.2, (delta * 40) / 3)

						local look = camera.CFrame.LookVector
						look = (look * XZ_VECTOR3).Unit
						
						local cf = CFrame.new(pos, pos + look)
						rootPart.CFrame = rootPart.CFrame:Lerp(cf, step)
					end
				end

				if self:IsInFirstPerson() then
					local cf = camera.CFrame
					local headPos, headLook = self:GetSubjectPosition(subject)

					if headPos then
						local offset = (headPos - cf.Position)
						cf += offset

						camera.CFrame = cf
						camera.Focus += offset
					end

					local shadowAngle = self:GetShadowAngle()
					local inView = cf.LookVector:Dot(shadowAngle)

					if inView < 0 then
						for real, mirror in pairs(self.HeadMirrors) do
							mirror.CFrame = real.CFrame + (shadowAngle * 9)
						end
					end

					self.MirrorBin.Parent = (inView < 0 and camera or nil)
				else
					self.MirrorBin.Parent = nil
				end
			end)
		else
			subject.AutoRotate = true
			self.MirrorBin.Parent = nil
		end
	end
end
