function OrientableBody.useAttributeAsSource(C)C:orientFromAttribute()C.attributeConnection=(C.character:GetAttributeChangedSignal(ATTRIBUTE)):Connect(function()C:orientFromAttribute()end)end function OrientableBody.destroy(C)if C.attributeConnection then C.attributeConnection:Disconnect()C.attributeConnection=nil end if C.renderStepConnection then C.renderStepConnection:Disconnect()C.renderStepConnection=nil end C.motor:setGoal({horizontalAngle=Otter.spring(0);verticalAngle=Otter.spring(0)})C.motor:onComplete(function()if C.motor then C.motor:destroy()C.motor=nil end end)end return OrientableBody
-- Use the character attribute (updated by the server) as the source of truth for body orientation
-- Intended to be used for replicated characters
function OrientableBody:useAttributeAsSource()
	self:orientFromAttribute()
	self.attributeConnection = self.character:GetAttributeChangedSignal(ATTRIBUTE):Connect(function()
		self:orientFromAttribute()
	end)
end

function OrientableBody:destroy()
	if self.attributeConnection then
		self.attributeConnection:Disconnect()
		self.attributeConnection = nil
	end
	if self.renderStepConnection then
		self.renderStepConnection:Disconnect()
		self.renderStepConnection = nil
	end

	self.motor:setGoal({
		horizontalAngle = Otter.spring(0),
		verticalAngle = Otter.spring(0),
	})

	self.motor:onComplete(function()
		if self.motor then
			self.motor:destroy()
			self.motor = nil
		end
	end)
end

return OrientableBody
